I need to convert:
{
"keys":
<ordered list of field names>
],
"values":
"<ordered list of field values, matching the keys field order>
]
}
What is the best way to do this in FME?
Input example: see attachment
I need to convert:
{
"keys":
<ordered list of field names>
],
"values":
"<ordered list of field values, matching the keys field order>
]
}
What is the best way to do this in FME?
Input example: see attachment
The ListKeyValuePairExtractor (from FME Hub) looks like a good choice here. You will have to expose the attributes afterwards.
Hi Geomancer,
Thats a fast and complete answer! Thanks a lot. I will try it and report back.
Cheers
The above example works like a charm. Thanks again!
But its getting a little more complicated. Instead of using a JSON file I am getting a JSON response from a RES API which I invoke with the HTTPCaller. After that I use a JSONValidator, JSONFormatter and JSONFragmenter to connect to the ListExploder, the rest is the same.
(The first part of this is from Exercise: Handling JSON - FME Web Services (imgscloudapps.com))
Configuration of the JSONFragmenter:
Configuration of the ListExploder
But I get an error with ListExploder:
What I am doing wrong?
I get it working with the HTTPCaller in connection with TempPathnameCreator and the FeatureReader
But it feels cleaner (best practice, less steps) to use the response_body, although I haven't got it working yet.
What do you think?
Passing _response_body to a JSONFlattener does the trick for me.
Thanks again geomancer! It works perfectly. You are a genius :)
The above example works like a charm. Thanks again!
But its getting a little more complicated. Instead of using a JSON file I am getting a JSON response from a RES API which I invoke with the HTTPCaller. After that I use a JSONValidator, JSONFormatter and JSONFragmenter to connect to the ListExploder, the rest is the same.
(The first part of this is from Exercise: Handling JSON - FME Web Services (imgscloudapps.com))
Configuration of the JSONFragmenter:
Configuration of the ListExploder
But I get an error with ListExploder:
What I am doing wrong?
You are getting the error because the list you've exposed doesn't actually exist in the data if you have processed it using the JSONFragmenter setup pictured above.
Try a JSONFlattener instead, this should give you the lists you need.
Alternatively, you could save your http response to a file instead of an attribute, and then read that back in as JSON with a FeatureReader
You're welcome, have a nice day! 🌞
You are getting the error because the list you've exposed doesn't actually exist in the data if you have processed it using the JSONFragmenter setup pictured above.
Try a JSONFlattener instead, this should give you the lists you need.
Alternatively, you could save your http response to a file instead of an attribute, and then read that back in as JSON with a FeatureReader
Thx eby! Really helpfull remarks. Your input is coming together below.