1

I have a JSON like this

{ 
    "a" : 1,
    "key_to_find" : "value_of_key",
    "nested" : {
         "value_of_key" : "real_value",
         "b" : 2
    }
}

I want to create a JSON Path expression to get "real_value", but I don't now the key "value_of_key" so I need to dynamically reference it. I tried something like:

$.nested['$.key_to_find']

but it doesn't work. How can I reference to root element value as key to get children values? Is that possible?

I need to use it inside AWS Step Functions, so no programming languages/libraries can be used.

1 Answer 1

2

References like this aren't part of JSON Path, though I think since you're using them inside AWS, you'll need to see exactly what they support. It varies. Widely.

We (the team working on the coming specification) have looked at the idea of a key() or index() function, however. You may find this discussion enlightening as well.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you, I am following the discussion in the link so correct me if I am wrong. Actually there is no solution for this, but you are already working on a possible functions implementation to address this kind of use cases?
There are some proposals, yes, but nothing has been added to the spec, yet, for this specific use case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.