Skip to main content
Open

More Robust JSON Query Support

Related products:Transformers

dbaldacchino1
Enthusiast

Currently what you can do with JSON Query in FME is very limited. It would be great to have more advanced support per https://docs.jsonata.org/simple, where for example once could extract the last item in array (json[-1]) or get objects in reverse oder (json[-2] etc.), get items in an array based on the value of an attribute (ex: json["columns"["type"='Data']]...maybe not exactly this syntax but you get the point...). This would avoid having to fragment a lot of useless data and then use Testers and TestFilters to weed out what you want.

6 replies

ebygomm
Influencer
Forum|alt.badge.img+39
  • Influencer
  • February 9, 2021

I'd like to see more examples too. Often I struggle to work out if the limitation is my JSON knowledge or the FME transformers


peter_s
Contributor
Forum|alt.badge.img+4
  • Contributor
  • March 2, 2021

I too was struggling with this the other day and came across takashi:s post here:

https://community.safe.com/s/question/0D54Q000080hL8CSAU/count-elements-in-json-array

I agree and would also like to see some more "reference" kind of documentation or links to that.


helmoetz
Supporter
Forum|alt.badge.img+14
  • Supporter
  • October 11, 2022

I was looking for a JSONQuery that lets me select an array member based on the value of one of the attributes. Allthough I could flatten the array and then use listSearcher, this can be time consuming for large arrays.


david_r
Celebrity
  • May 3, 2023

The current "json query" support in FME is pretty weak when working with complex structures and I believe it merits an upgrade seeing how how common JSON-driven APIs have become.

It would be incredibly helpful to have full JsonPath support in FME, so that we could e.g. write queries like this

$.content.areas[?(type=='DISTRICT')].name

to get the name of all the areas of type "DISTRICT", without resorting to the ListExploder + Tester pattern.

More examples here: https://github.com/json-path/JsonPath


robd
Contributor
Forum|alt.badge.img+2
  • Contributor
  • September 15, 2023

Generating a JSON Query can be a bit of a pain too in the JSON transformers. I often write the json body from a HTTP call to a file and use the JSON reader to help me generate the JSON Query. I'd like to see the same kind of GUI element we have on the JSON reader where you can select the level in the JSON hierarchy to extract/process JSON applied to transformers:

 

imageIt seems to be there, but only a text entry to define the query. When caching is on, the transformers such as JSONExtractor could read the cache to build the query tree then offer the user a way to define the JSON Query using a GUI rather than free text


koenterralytics
Contributor
Forum|alt.badge.img+8

This is also my current work-around. It would save a lot of time if it is possible to skip these steps each time.


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