Craft a JSONpath expression so that it retrieves only a specific value?
Posted
by Alex
on Stack Overflow
See other posts from Stack Overflow
or by Alex
Published on 2010-05-26T21:05:19Z
Indexed on
2010/05/28
23:52 UTC
Read the original article
Hit count: 300
Hello,
I have some JSON of which the following is a small sample:
results": {
"div": [
{
"class": "sylEntry",
"id": "sylOne",
"div": [
{
"class": "sT",
"id": "sOT",
"p": "Mon 11/17, Computer work time"
},
{
"class": "des",
"id": "dOne",
"p": "All classes Siebel 0218"
}
]
},
I would like to only retrieve the "p"
content for the div element with class "sT"
. I would like to use a loop and doing something like this:
var arrayOfResults = $.results..div.p
does not work because I only want to retrieve the p value for the div element with class "sT"
.
So how do I construct my JSONpath so that it will retrive the array of p elements that are contained within the divs class "sT".
Thanks!!
© Stack Overflow or respective owner