JSON Path/XPath get not existing entries as empty cases

Hello,

I have a JSON File which looks like:

“results” : [ {
“id” : “abr23”
“items” : [ {
“Number” : “123”
} ]
}, {
“id” : “dewn42”
“items”: [ {
“Number” : “122”
}, {
“Number” : “133”
} ]
}

So you can have multiple numbers (at least one). I just need to know if there is more than one number per each id. Basically i tried Column Number1 = $…[‘items’][0][‘Number’] which returns me the first number and Column Number2 = $…[‘items’][1][‘Number’] for the second. The problem is that both return a list, but they differ in length. So for example if I have 30 ids I will get 30 Number1’s but e.g. only 10 Number2’s and I lose the link between the two numbers and their corresponding ids.

In the second list their should be empty entries if there is no number2 for any id. I would also be sufficient to get a binary value (0 = ‘only one number’, 1 = ‘at least two numbers’).

I appreciate your help.

Regards,
Armin

Solved it by using this solution XPath selection type

But the question is, is it still possible to use some kind of count in Knime XPath?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.