Forum Discussion

Henchway's avatar
Henchway
Contributor
6 years ago
Solved

Retrieving a JSON object key with jsonPath

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:

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:

Best regards
Thomas

  • Hi @Henchway,

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

    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:

    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