Why does RestAssured use Groovy's Gpath and not Jayway's JsonPath ?

1,360 views
Skip to first unread message

Malloc Kilobyte

unread,
Nov 30, 2015, 2:01:23 AM11/30/15
to REST assured
Hi,


In the RestAssured Usage Guide I can find the following:
"Note that the "json path" syntax uses Groovy's GPath notation and is not to be confused with Jayway's other JsonPath syntax."

Since I like the Jayway's JsonPath syntax more, I'm wondering why is that: is it deprecated in some way or just not fitting the assertion framework ? Or is GPath just more popular ?
Is there a way to plug Jayway's JsonPath in and replace GPath ?



Regards

Johan Haleby

unread,
Nov 30, 2015, 2:16:38 AM11/30/15
to rest-a...@googlegroups.com
Hi, 

There are many reasons and here are some (no particular order):

  • REST Assured was created before Jayway's JsonPath
  • REST Assured is built in Groovy and thus it was natural to take advantage of its data structures and its query language.
  • GPath also works for other data formats such as XML and HTML which means that once you learn GPath you can apply to other types of data in an easy manner
  • GPath has historically been more capable than JsonPath (although today I don't think this is much to worry about)
I've wanted to support Jayways JsonPath for a long time but it'll take some effort to do so. Also, as a long term goal, I'd like to refactor REST Assured and get rid of Groovy in the core module. That way you should be able to hook in different "path providers", not just Jayway's JsonPath. So today there's no way to use Jayway's JsonPath. But of course they are easy to combine, for example:

String store = get("/store").asString(); // Rest Assured
// Jayway JsonPath
List<String> authors = JsonPath.read(store, "$.store.book[*].author");
// AssertJ
assertThat(authors).contains("author1").contains("author2);

Contributions of any kind are of course welcome. 

Regards,
/Johan


--
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...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Malloc Kilobyte

unread,
Nov 30, 2015, 2:25:08 AM11/30/15
to REST assured
Ok, Thanks a lot for comprehensive explanation.
Reply all
Reply to author
Forward
0 new messages