Savage1956 / rest-assured

Automatically exported from code.google.com/p/rest-assured
0 stars 0 forks source link

JSON parser has problem with parsing array of elements with key equal "properties" #397

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
1. Prepare JSON like:
{
    "features": [
        {
            "type": "Feature",
            "geometry": {
                "type": "GeometryCollection",
                "geometries": [
                    {

                        "type": "Point",
                        "coordinates": [
                            19.883992823270653,
                            50.02026203045478
                        ]                     
                    }
                ]
            },
            "properties": {
                "gridId": 6
            }
        },
        {
            "type": "Feature",
            "geometry": {
                "type": "GeometryCollection",
                "geometries": [
                    {
                        "type": "Point",
                        "coordinates": [
                            19.901266347582094,
                            50.07074684071764
                        ]
                    }
                ]
            },
            "properties": {
                "gridId": 7
            }
        }
   ]
}
2.
Here are two examples of code. First one is working, second is not.
List<String> typeList= JSON.jsonPath().get("features.geometry.type"); //It's 
working
List<Integer> gridIdList= JSON.jsonPath().get("features.properties.gridId"); 
//It's not working

In second case I should get list of all gridIds but its not working, it returns 
null. I 
assumed it is connected with property name = "properties". The example above is 
valid GeoJson format.

What is more interesting I can do something like that and it's working:
Integer gridId = JSON.jsonPath().get("features[0].properties.gridId"); 

Version: 2.4.0

Original issue reported on code.google.com by kamil.ni...@gmail.com on 21 Apr 2015 at 9:07

GoogleCodeExporter commented 8 years ago
As a workaround I think you can do "features.'properties'.gridId"

Original comment by johan.ha...@gmail.com on 7 Jun 2015 at 4:49