Hello Knime Community,
maybe a easy to answer question.
Via an API Request I receive a JSON File. In this JSON File a price-tag is included, but it can appear in tag number 1 or tag number 3 and so on. Just the name is fix PRICE.
I see there is a Node JSON Path Dictionary, but I’m now sure how to use it in this case.
Thanks and regards,
Hi @sven-abx , this is more of a JSON Path syntax question since Knime works the same way as how regular JSON Path works.
I use this page as a good guide:
Do you happen to have an (anonymized) example of your JSON to work with? Or the workflow it is included in? A pratical solution is always better than a theoretical solution
If PRICE on its own is a unique term and appears at the same hierarchical level, you should be able to gather this with just using a wildcard.
Assume a recipe book:
If I want to extract the name of each recipe individually manually, I would add:
Since the name is a unique term, I can extract them all at once by converting the number into a wildcard and create a list of it.
This gives me the value of all name attributes, regardless of its location in the JSON object.
In this example, the name tag is located in different positions. (3rd and 1st)
Get Attribute from JSON by Name.knwf (13.5 KB)
Something like this and @bruno29a great resource should get you in the right direction. If not, an example of your use case would be helpful
hi @bruno29a and @ArjenEX ,
thanks for your answers.
My problem is, that I can’t go the “name” way, because the JSON looks like this:
So, I need to figure out, how to get every value, when name equals “PRICE/AMOUNT”.
Thanks and regard,
I see @sven-abx
In that case you should be able to get it with something along the lines of:
This depending on your actual JSON structure. Based on the limited screenshot I re-created something in a basic form, with a list and a few items. The code searches for the item PRICE/AMOUNT and then picks the values element.
If you have more than one instance, creating a list, ungrouping, cleansing steps etc are to follow.
I tried to solve it via JSON Dictonary, this was my mistake. Just followed your steps and it is working.
Now, Data Cleaning
Thanks and BR,
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.