Campoie / rest-assured

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

Properties reserved JSON word? #231

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

Execute the following code:

new JsonPath("[{\"property\":\"test\"}]").get("property");

Returns:

ArrayList with 1 value "test" = CORRECT

===============

Execute the following code:

new JsonPath("[{\"properties\":\"test\"}]").get("properties");

Returns:

LinkedHashMap with 2 values
- "class" = "class java.util.ArrayList"
- "empty" = "false"

NOT CORRECT

Is "properties" a reserved JSON, JsonPath,... word? I can't find any 
information on this.

Kind regards,

Geert

Original issue reported on code.google.com by vanheus...@gmail.com on 30 Apr 2013 at 2:38

GoogleCodeExporter commented 9 years ago
Hi, 

This looks like a bug. "properties" is a reserved word in Groovy which is not 
handled correctly by REST Assured. For now please escape it manually, new 
JsonPath("[{\"properties\":\"test\"}]").get("'properties'");. 

Thanks for reporting.

Original comment by johan.ha...@gmail.com on 2 May 2013 at 6:43

GoogleCodeExporter commented 9 years ago
Ok so there seems to be two issues here. First off all "properties" is a 
reserved key word in Groovy and RA didn't escape it properly. How ever even 
though it's escaped properly it doesn't give the same result. Here's pure 
Groovy code:

def json = new 
groovy.json.JsonSlurper().parseText("[{\"properties\":\"test\"}]");
json.'properties'

Returns  [class:class java.util.ArrayList, empty:false]

How ever:

def json = new groovy.json.JsonSlurper().parseText("[{\"property\":\"test\"}]");
json.'property'

Returns [test]

So it seems to be an issue/feature in Groovy and I don't think it's worth (or 
even a good idea) to do anything about this.

How ever I will regard the issue as closed since "properties" is now 
automatically escaped in RA.

Original comment by johan.ha...@gmail.com on 29 May 2013 at 12:05