Hi @sbarn
Could you share us your fmwt ( Workespace Template ) or your source JSON ?
Thanks,
Danilo
Hi @sbarn,
When I am working with JSON I find it useful to first use a JSONFlattener transformer, as this will allow me to view all the attributes in the Feature Information window of Visual Preview/Data Inspector and it will show you the structure to access each of the attributes which should be used to form your JSON Query.
So once you know how the attributes are stored there are a couple of options as to how you can extract them from the JSON string:
Option 1:
Expose the attributes directly in the JSONFlattener, using the 'Attributes to Expose' parameter. You'd need to use the full attribute name listed in the Feature Information window e.g.
array{0}.assetScores.assetScore{0}.rating
array{0}.assetScores.assetScore{0}.score
and then use a BulkAttributeRenamer to remove the array{0}.assetScores.assetScore{0} prefix.
Option 2:
Expose the attributes using a JSONFragmenter, this allows you to first perform a JSON Query on the string so that you can access the assetScore element and expose the attributes using the names rating and score meaning you don't have to rename them afterwards.
Option 3:
Use the JSONExtractor to perform a JSON Query for each attribute you wish to expose.
The workspace attached demonstrates all three options jsonextractattributes.fmw. Which option you choose usually depends on the complexity of your JSON and what attributes you want to extract from the JSON. Please note, if this is not the full JSON string the query will likely be more complex, but hopefully this demonstrates how you can find the right query and should get you started.
Take a look at this article for more info on working with JSON.
Thank-you @hollyatsafe I picked Option 1 and it worked a treat.