Question

JSONUpdater

  • 11 October 2016
  • 4 replies
  • 33 views

Does anyone have an example of using the JSONUpdater? I am trying to update multiple Json files (up to 50) without opening them up and finding my value to change but am looking for FME to help fill this gap.

 

Thank you in advance!

4 replies

Badge +22

I use it a lot, but generally one JSON file at a time. If you want to run multiple files at the same time then you will need an ID to group your documents and update by.

 

 

The original JSON goes to the document port. You can have features with an attribute containing the path to the JSON file, or you can have features with an attribute containing the JSON object.

The features containing the update information go to the update port

You can specify the type of update, path, index (as name or value), type and Value. Everything but he Update type can come from an attribute on the feature, or can be hardcoded.

 

 

In this screenshot, the json object contains a path to an image file, which FME reads and determines the resolution, coordinate system etc and update the JSON with the correct information.

 

 

The result cannot be written directly to a file, but is an attribute attached to the document features.

Thank you JDH for the quick reply.

I guess where I am struggling on this is I am not sure what to put in the "JSON Path" and what is actually coming in the "Updates" port.

I hope to use this updater to update web app config files so my json doesn't contain any "features".

Thanks again for the help.

Badge +22

Thank you JDH for the quick reply.

I guess where I am struggling on this is I am not sure what to put in the "JSON Path" and what is actually coming in the "Updates" port.

I hope to use this updater to update web app config files so my json doesn't contain any "features".

Thanks again for the help.

Can you give a snippet of what of how your json is structured and what you want to update?

 

 

Badge +6

If you're having trouble figuring out JSON paths, I'd recommend installing FME 2017 beta. You can use the new tree view in the JSON reader to select the elements you want to extract as features. This will auto-generate the JSON query needed for the extraction. You can then use this same query in any of the JSON extraction transformers (JSONFragmenter, JSONUpdater etc) whether in FME 2017 or 2016. Note that the JSONUpdater functions much like the XMLUpdater, so you can look at the docs for that. In general the Document port takes input features for the base JSON document(s) to be modified, and the Update port receives features that provide values or JSON fragments to use for the updates.

Reply