0

I'm trying to convert the following JSON-object

{"myFirstArray":[[266.38,0.196],[266.37,3.399],[266.35,0.192],[266.33,0.101],[266.32,0.214],[266.29,0.203],[266.24,6.54],[266,1],[265.94,4.617],[265.73,2.13],[265.72,6.576],[265.71,0.049],[265.68,17.87],[265.67,39.191],[265.51,0.01],[265.18,0.793],[265.11,0.04],[265.01,0.544],[265,22.919],[264.82,3.493]],"mySecondArray":[[268.54,0.354],[268.29,0.3],[268.26,1.336],[268.15,0.01],[267.97,7.247],[267.96,10],[267.88,0.052],[267.77,0.013],[267.74,40.992],[267.71,20],[267.7,0.506],[267.65,0.075],[267.53,5.568],[267.49,0.064],[267.48,0.096],[267.34,0.71],[267.23,2.675],[267.19,32],[267,1.05],[266.9,0.98]],"simpleObject":"1234"}

to the Java class MyObject (below), I'm currently using GSON, but can not find any documentation or examples on how to convert arrays of unnamed values.

public class MyObject{
    Pair myFirstArray[];
    Pair myFirstArray[];
    int simpleObject;
}
public class Pair {
    float foo;
    float bar;
}
2
  • Possible duplicate: stackoverflow.com/questions/14205743/… Commented Aug 9, 2015 at 12:13
  • 2
    have you tried jsonschema2pojo.org ? Copy your JSON int the textarea and select JSON as source. Select the necessary settings you would like to receive, for example GSON und click on preview. Test the retrieved classes with it. For the unnamed arrays, it will create something like this: private List<List<Double>> myFirstArray = new ArrayList<List<Double>>(); Commented Aug 9, 2015 at 12:15

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.