Skip to main content

Dear FME community.

 

I need help for using the JsonTemplater transformer.

I've multiple data source and I've to build a complex json with sub objects like that (this is with only one level but in the real case I've more sublevels) :

eeeeI make an unperfect example join to this question :-)

 

Thanks for your help.

To use the JSONTemplater with "sub-levels" you should make use of the Sub Templates in the transformer:

JSONTemplator_parametersHere I've created the Root of the json document as:

JSONTemplator_rootWith SUB_ROOT and SUB_SUB_ROOT templates defined in the Sub Templates section as:

JSONTemplator_subrootand

JSONTemplator_subsubrootrespectively. The call in SUB_ROOT to bring in the SUB_SUB_ROOT template includes paramters to only include the sub-sub-features that are associated with the sub-feature. In this case both features have the same "sub_feat" value.

All you need to do is then send into the JSONTemplator features for each level, one for each Root, then all the sub-level and finally all the sub-sub-level features into their allocated input ports. Grouping of the subfeatures occurs when they carry the same feature identification attribute value as is present on the level above.

 

Running some sample data through the JSONTemplator and JSONFormatter (for PrettyPrint) we get:

JSON_outputI hope this help you to solve your json issue.


Reply