span8
span4
span8
span4
I am trying to generate a JSON file that includes elements like this one:
But I have problems with the "positions" property.I can´t reproduce it.I can get and array ([] instead of {}) and each element like "9": [220000, 3230000] with non desired {} at the begining and the end.
I attach the full project (jsontemplater.zip) with the target.json that I need.
Thanks in advance.
Hi,
Try changing the value for the "positions" key in la ISLA subtemplate to this:
-----------------------
"positions": {| fme:process-features("POSITIONS", "id_isla", fme:get-attribute("id")) |}
-----------------------
Notice "|" in wrapping "{|" and "|}"."{| |}" is a merge constructor, used to merge several objects.
I ran your workspace with the "{| |}" change, instead of an array of objects you'll get a single merge object.
Hope this helps.
Juan
Ah yes...it's a royal pain to insert key-value pairs from features into an object.Arrays/lists are easy though...And if you omit the {} in your POSITIONS sub-template, the JSONTemplater throws an error - I wish it would allow for text in the JSONTemplater window without enclosing {} as long as the whole resulting document proves to be valid JSON!
I have been struggling with this before and ended up creating the objects with a PythonCaller and the JSON library...
© 2019 Safe Software Inc |Legal