I'm using Play Framework with Scala. I have the following structure for JSON being returned by an upstream server. This is just a representation
{
"key": "some-key",
"suspendData": {
"d": [
[
"arbitrary-objects/strings"
],
[
"random-value",
[
"arbitrary-objects/strings"
],
[
[
"value1",
"important-item",
[
"important-key-1"
],
"arbitrary-values/objects"
],
[
"value2",
"important-item-2",
[
"important-key-2"
]
]
]
]
]
}
}
The only facts that I have is that the data will be located somewhere within $.suspendData.d[1]. I know the value that I am searching for which is important-key-1. The value can be nested deeper or it could be on a different index within `d[1]. How do I approach the problem of finding whether
- The key exists in the JSON that has been obtained from the upstream server.
- The path where the key was found, so I can find other keys based on the same path. This is a reverse lookup problem.
I can currently only think of getting $.suspendData.d[1] and then loop to find whether such properties exist.
Again, I can't find a proper way of doing this via JsPath. I know the JsonPath equivalent, but can't find the right way through existing Play JSON support.