I want to create multi-level JSON (nested) with a specific attribution. I have followed this article. I need to get this structure:
Following the tutorial I'm not able to add more attributes to the top layer as is written also in JSONTemplater help. I need to get something like this:
[{
"category": "kategorie1",
"caption": "A",
"features" : [
{
"name" : "A1",
"rotation" : "0",
"bbox" : [ -733690, -1024463, -732733, -1023916 ]
},
{
"name" : "A2",
"rotation" : "0",
"bbox" : [ -733093, -1024114, -732939, -1023902 ]
},
...
]
},
{
"category": "kategorie2",
"caption": "B",
"features" : [
{
"name" : "B1",
"rotation" : "0",
"bbox" : [ -732924, -1023936, -732707, -1023601 ]
},
{
"name" : "B2",
"rotation" : "0",
"bbox" : [ -733058, -1023918, -732884, -1023584 ]
},
...
]
}
]
All I can get so far is this:
{
"A" : [
{
"name" : "A1",
"rotation" : "0",
"bbox" : [ "-733690", "-1024463", "-732733", "-1023916" ]
},
{
"name" : "A2",
"rotation" : "0",
"bbox" : [ -733093, -1024114, -732939, -1023902 ]
},
...
],
"B" : [
{
"name" : "B1",
"rotation" : "0",
"bbox" : [ -732924, -1023936, -732707, -1023601 ]
},
{
"name" : "B2",
"rotation" : "0",
"bbox" : [ -733058, -1023918, -732884, -1023584 ]
},
...
]
}
My Templater setup is as follows:
ROOT
{|
fme:process-features("OBLAST")
|}
OBLAST sub-template
{
fme:get-attribute("pismeno") : [
fme:process-features("PRVKY", "pismeno", fme:get-attribute("pismeno"))
]
}
PRVKY sub-template
{
"name": fme:get-attribute("CISLO"),
"rotation":"0",
"bbox": [fme:get-attribute("_xmin"),fme:get-attribute("_ymin"),fme:get-attribute("_xmax"),fme:get-attribute("_ymax")]
}
I would need to have the top level as separated object with more key-value pairs (attributes) as shown above - like in the last level features. If I try to add keys as in PRVKY sub-template to the OBLAST sub-template I get parsing error with invalid syntax.
Can someone guide me, please? I attach complete files. What I can get (bookmarks.json) and what I would like to get (bookmarks_desired.json).