Page tree
Skip to end of metadata
Go to start of metadata

Here there are some samples of Jsonpath.

Assume, we have a json response as follows

{"store": 
[  
	{
		"title": "Book One",
		"price": 23
	},
  	{
		"title": "Book Two",
		"price": 34
	},
  	{
		"title": "Book Three",
		"price": 45
	},
  	{
		"title": "Book Four",
		"price": 56
	}
]
} 
jsonpathresult
store.size()4
store[0].titleBook One
store[2].titleBook Three
store.findAll { it.price > 50 }.title[0]Book Four
store.find { it.name == 'Book Three' }.price
45
store.collect { it.price }.sum()158 (which is 23 + 34 + 45 + 56)

Note that the JsonPath implementation uses Groovy's GPath syntax and is not to be confused with Jayway's JsonPath implementation.



  • No labels