โ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