cancel
Showing results for 
Search instead for 
Did you mean: 

Jsonpath to get value with @

walkerline117
Contributor

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

1 ACCEPTED SOLUTION

tstack
Former Employee

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.

View solution in original post

6 REPLIES 6

In the SnapLogic Designer, the dropdown for expression properties will fill in the correct path with the appropriate quoting:

at-path

Also, in the Mapper, you can drag the property from the schema view on the left into the expression property and it should do the same:

at-path2

del
Contributor III

also… if you get the syntax correct, http://jsonpath.com/ should work for you.

I corrected the input syntax for the below, and it worked for me

image