I am trying to parse json to java.
I have the following string that is valid json according to jsonlint.com
private final static String LOC_JSON = 
         "["
        +"{"
        +"  \"lat1\": 39.737567,"
        +"  \"lat2\": 32.7801399,"
        +"  \"long1\": -104.98471790000002,"
        +"  \"long2\": -96.80045109999998"
        +"},"
        +"  ["
        +"      {"
        +"          \"lat\": {"
        +"              \"b\": 38.88368709500021,"
        +"              \"d\": 40.620468491667026"
        +"          },"
        +"          \"long\": {"
        +"          \"b\": -105.75306170749764,"
        +"          \"d\": -104.675854661387"
        +"          }"
        +"      }"
        +"  ]"
        +"]";
I am trying to parse it into an object and I get the following error. "Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2"
            Gson gson = new Gson();
        BoxSearch b = gson.fromJson( LOC_JSON, BoxSearch.class ); 
BoxSearch consists of this.
private Number lat1;
private Number lat2;
private Number long1;
private Number long2;
private Boxes[] boxes;
Boxes is a Latitude object and a Longitude object which are both defined identical.
private String b;
private String d;
I can parse the higher level attributes (lat1,lat2,long1 and long2) into a more simple BoxSearch object that only has those 4 attributes. The trouble comes when the json and the object are more complex. Is it even possible to do what I am trying?
I hope I have provided enough information to get some help. I would be happy to provide more info or even a test project if need be. I am running this as a junit test.
Thanks.
 
     
     
    