Skip to main content
Question

Flatten API response body into features. How do I go about this response? It's quite different.

  • October 12, 2023
  • 1 reply
  • 16 views

Hello,

 

I have a response from one of the APIs I'm using that is formatted as the following example:

{
 "measurements": {
 "timestamps": [
 1504377563,
 1504378166,
 1504378372
 ],
 "waterGround_mm": [
 -5032,
 -5030,
 -5031
 ],
 "waterNAP_mm": [
 -7532,
 -7530,
 -7531
 ],
 "validity": [
 null,
 null,
 1
 ]
 }
}

Now, I can flatten this using FME to the following lists:

_timestamps{0}: 1504377563
_timestamps{1}: 1504378166
_timestamps{2}: 1504378372
_waterGround_mm{0}-5032
_waterGround_mm{1}-5030
_waterGround_mm{2}-5031
_waterNAP_mm{0}-7532
_waterNAP_mm{1}-7530
_waterNAP_mm{2}-7531
_validity{0}: <null>
_validity{1}: <null>
_validity{2}: 1

Now my idea would be to rename these lists somehow to _list{}.measurement, _list{}.waterGround_mm and so on, and then use the ListExploder to explode _list{} to features. Sadly I can't find a way to properly rename _measurement{} to _list{}.measurement. Also, just trying to explode _measurements{} takes a long time with 30.000 records.

 

Is this the proper way to go about tackling this issue? What other solutions would you all suggest?

 

Thanks in advance.

1 reply

david_r
Celebrity
  • October 12, 2023

Not sure I understand what you need, but try the attached workspace.

And yes, exploding large number of features is unfortunately relatively slow in FME. But be sure to try the very latest version.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings