Have you tried Map map = get("/x").as(Map.class) or Map<String, ValueClassObj> map = get("/x").jsonPath().getMap("$", String.class, ValueClassObj.class)?
--
You received this message because you are subscribed to the Google Groups "REST assured" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
[
{
"entity_id":"24",
"website_id":"1",
"group_id":"2",
"created_at":"2013-03-28 18:57:17",
"disable_auto_group_change":"0",
"firstname":"Jack",
"lastname":"Fitz",
"created_in":"Admin",
"prefix":null,
"suffix":null,
"taxvat":null,
"dob":"2001-01-03 00:00:00",
"reward_update_notification":"1",
"reward_warning_notification":"1",
"gender":"1"
}
]
Enter code here...FAILED: getCustomerByEmailB
java.lang.IllegalArgumentException: Invalid JSON expression:
Script1.groovy: 1: unexpected token: * @ line 1, column 29.
$.*
^
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured...@googlegroups.com.
Johan,
I didn't see this reply until just now.
I have done a little more testing, my path was probably wrong "$".
I went to jsonpath tester and found that if I used "$.*" i could get back and array
but rest-assured doesn't like "$.*"
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured+unsubscribe@googlegroups.com.
Johan,
I understand the two testers use two different types of jsonpath - GPath and Rest-Assurred JsonPath.
I totally agree - its extremely confusing to use the same name for both ...
My point was if "$.*" works on both testers it should work with rest-assured regardless of which of the two JsonPath libs
are used. Am I correct with this assumption?
From your first answer above, it sounds like trying to grab the map of <String, Customer> directly from the root - is either a bug or was never implemented in RA.
I will enter an issue as you suggested.
In the end, I'm just looking for a way to get the Customer data out of the response.
In Jersey I use this:
Map<String, Customer> map = response.readEntity(new GenericType<Map<String, Customer>>() { });
Can you suggest a correct "path" string that will get me the data I'm looking for?
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured+unsubscribe@googlegroups.com.
On Mon, Nov 28, 2016 at 8:44 AM, Tim R <tim...@gmail.com> wrote:Johan,
I understand the two testers use two different types of jsonpath - GPath and Rest-Assurred JsonPath.
I totally agree - its extremely confusing to use the same name for both ...I think you've missunderstood. REST Assured includes a library called json-path (group id io.rest-assurued) which uses the GPath syntax. Then there's a Jayway library called jsonpath which uses the "json path" syntax and this is totally different from rest-assured. These two have just two things in common, the names are confusingly similar and they can extract values from a json document (with different syntax).
My point was if "$.*" works on both testers it should work with rest-assured regardless of which of the two JsonPath libs
are used. Am I correct with this assumption?No
From your first answer above, it sounds like trying to grab the map of <String, Customer> directly from the root - is either a bug or was never implemented in RA.
I will enter an issue as you suggested.It's not a bug in RA, I would think it's a feature suggestion to the groovy-json module (JsonSlurper).
In the end, I'm just looking for a way to get the Customer data out of the response.
In Jersey I use this:
Map<String, Customer> map = response.readEntity(new GenericType<Map<String, Customer>>() { });
Can you suggest a correct "path" string that will get me the data I'm looking for?Hmm maybe you can do like this (with REST Assured json path):JsonPath jsonPath = JsonPath.from(<json>)Map<String, Customer> customers = jsonPath.getMap("$", String.class, Customer.class)
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured+unsubscribe@googlegroups.com.