PDA

View Full Version : xpath on json returned from server



satish.vicky
31 Mar 2011, 1:55 AM
Hi All,

Does ExtJS provide the support for writing xpath on json data that is fetched from the server.If yes can you please post an example of it.

fay
31 Mar 2011, 2:53 AM
XPath is for querying XML, not JSON. What is it that you are trying to do? Have you looked at JSONPath (http://goessner.net/articles/JsonPath/)/jsonpath (http://code.google.com/p/jsonpath/)/jspath (http://hackage.haskell.org/package/jspath)?

satish.vicky
31 Mar 2011, 4:22 AM
Ok let me put it in other way,How to query on json data using extjs.

fay
31 Mar 2011, 5:04 AM
What is it that you are trying to do?

It would help if you provided some context. How are you loading the JSON? Is it in a store - which provides many methods to query the data - or are you decoding responseText from an Ajax.request?


Have you looked at JSONPath (http://goessner.net/articles/JsonPath/)/jsonpath (http://code.google.com/p/jsonpath/)/jspath (http://hackage.haskell.org/package/jspath)?

Did you look at these?

satish.vicky
31 Mar 2011, 6:09 AM
I am decoding the JSON data which is fetched from server on this data i need to query on the json.

satish.vicky
31 Mar 2011, 6:14 AM
I have checked jsonpath but how can i use that in extjs are there any examples of how can i use.

take the following json sample

{ "store": {
"book": [
{ "category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{ "category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 12.99
}]
}}

fay
31 Mar 2011, 6:15 AM
And what is it that you want to extract/query from that json???

satish.vicky
31 Mar 2011, 8:46 PM
from the below sample of json i want to get the value of 1st book author name.

{ "store": {
"book": [
{ "category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{ "category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 12.99
}]
}}