cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieving a JSON object key with jsonPath

Henchway
Contributor

Hi everyone,
i’m having troubles retrieving the key of a JSON object which is usually possible via the ~ sign.

I hope the images render properly, this is possible via regular jsonPath, however i was not able to get that working with the jsonPath function in Snaplogic:
image

image

Does anyone have an idea on how i can get my hands on the key of that object in Snaplogic?
Sadly i’m only getting the object itself without the name:

image

Best regards
Thomas

1 ACCEPTED SOLUTION

dimitri_hristov
Contributor

Hi @Henchway,

I assumed that $…questions is a JSON Object. So for this input to the Mapper Snap:
Mapper_input ,

I entered this expression in the Mapper:

$entity.value.design.questions.filter((value,key)=>value.label == "Target Application ID").keys()

and assigned it to the $key field. I then got this in the Mapper’s output:
Mapper_output

If I am incorrect in my assumptions, perhaps you can provide us with sample input data you need processed in a textual format, so that I’d be able to work with that.

BR,
Dimitri

View solution in original post

2 REPLIES 2

dimitri_hristov
Contributor

Hi @Henchway,

I assumed that $…questions is a JSON Object. So for this input to the Mapper Snap:
Mapper_input ,

I entered this expression in the Mapper:

$entity.value.design.questions.filter((value,key)=>value.label == "Target Application ID").keys()

and assigned it to the $key field. I then got this in the Mapper’s output:
Mapper_output

If I am incorrect in my assumptions, perhaps you can provide us with sample input data you need processed in a textual format, so that I’d be able to work with that.

BR,
Dimitri

Thank you very much, that is exactly what i was hoping to achieve.
I am fighting with jsonPath ever since, it’s great to know that i can just use the filter method on the object instead.

Best regards
Thomas