10-30-2017 01:09 PM
I have below json body, how would I use jsonpath in a mapper to get all 'name’s?
Its easier for me if the json have ‘name’ instead of ‘@name’…
Not sure how to get all those values in a mapper
{
“response”:
{
“lst”:[
{
@“name”:“terms”,“lst”:{“@name”:“user_query”,“int”:[
{“@name”:“solar energy”,“$”:“4651”},
{“@name”:“script”,“$”:“1993”},
{“@name”:“scenario planning”,“$”:“641”},
{“@name”:“strategy under uncertainty framework”,“$”:“627”},
{“@name”:“smed game”,“$”:“601”},
{“@name”:“specialty pharma”,“$”:“458”},
{“@name”:“specialty pharmaceutical”,“$”:“446”},
{“@name”:“specialty care”,“$”:“444”},
{“@name”:“supply chain”,“$”:“406”},
{“@name”:“sap”,“$”:“310”}]}}
]
}
}
Thanks
Solved! Go to Solution.
10-30-2017 01:37 PM
I’m not quite sure what you’re asking, can you give an example of the output you want?
If you’re asking how to reference a field with a special character, like the @ symbol, you can quote it like so:
['@name']
If you want to collect all the ‘@name’ values at any level, you can do:
jsonPath($, "$..['@name']")
That will return a list containing all the values.
10-30-2017 01:37 PM
I’m not quite sure what you’re asking, can you give an example of the output you want?
If you’re asking how to reference a field with a special character, like the @ symbol, you can quote it like so:
['@name']
If you want to collect all the ‘@name’ values at any level, you can do:
jsonPath($, "$..['@name']")
That will return a list containing all the values.
10-30-2017 01:43 PM
Thanks
is there a tool that can help us to debug such jsonpath expression, i have tried @name in http://jsonpath.com/
However, such @name is not valid in this website.
11-21-2017 08:33 AM
I use this one: http://www.jsonquerytool.com/
{
“response”: {
“lst”: [{
“@name”: “terms”,
“lst”: {
“@name”: “user_query”,
“int”: [{
“@name”: “solar energy”,
“$”: “4651”
}, {
“@name”: “script”,
“$”: “1993”
}, {
“@name”: “scenario planning”,
“$”: “641”
}, {
“@name”: “strategy under uncertainty framework”,
“$”: “627”
}, {
“@name”: “smed game”,
“$”: “601”
}, {
“@name”: “specialty pharma”,
“$”: “458”
}, {
“@name”: “specialty pharmaceutical”,
“$”: “446”
}, {
“@name”: “specialty care”,
“$”: “444”
}, {
“@name”: “supply chain”,
“$”: “406”
}, {
“@name”: “sap”,
“$”: “310”
}
]
}
}
]
}
}
And use this: $[@name] or $.[@name]
11-27-2017 01:52 PM
thank you for your information