Hi @Daniel_Weikert , I would be interested to see how we can use JSON Path here.
If the data was like this:
{
"GIVENNAME": [
"May"
],
"MIDDLENAME": [
"Green"
],
"SURNAME": [
"Dowman",
"Hinna"
]
}
Then for me it would make sense to use JSON Path. You can go to the GIVENNAME, or MIDDLENAME or SURNAME paths, no matter how many GIVENNAME or MIDDLENAME, or in this example, SURNAME you have, it would be ok.
For example:
{
"GIVENNAME": [
"May",
"Mary"
],
"MIDDLENAME": [
"Green",
"Herbs"
],
"SURNAME": [
"Dowman",
"Hinna"
]
}
That would not be a problem using JSON, you still have 3 paths.
But if I translate the above example to the current given format, it would look like:
[ {
"string" : "May",
"termType" : "GIVENNAME"
}, {
"string" : "Mary",
"termType" : "GIVENNAME"
}, {
"string" : "Green",
"termType" : "MIDDLENAME"
}, {
"string" : "Herbs",
"termType" : "MIDDLENAME"
}, {
"string" : "Dowman",
"termType" : "SURNAME"
}, {
"string" : "Hinna",
"termType" : "SURNAME"
} ]
Now, suddenly I got 6 pairs of paths vs 4 pairs from the original data.
If I have to access each path, I have to access them by position/index, for example <some_level>.string[2]
or <some_level>.termType[2]
, and we can also speculate that the amount of pairs will be dynamic per record, so you would need to determine what’s the n
position/index will be (<some_level>.string[n]
).
Obviously it can be done, but it looks more work to implement, such as figuring out the size of n, looping to retrieve the string[0] and termType[0] to string[n] and termType[n] (I am guessing that’s how it got implemented in the Java snippet), etc.
I would still be interested to see how you implement it with JSON Path though.