Skip to main content

Hi,

I want to add different suffix to different attributes, 'Filename' in a jason-file.

FilenameSuffixABC_123DEF_456GHI_789JKL_102MNO_103PQR_104

I have managed building a list with the added suffix, and tried unsuccesfullty to replace the array value using JSONUpdater.

 

Another approach I tried was to merge the generated list using Featuremerger. I get the correct lists, but are unable to write them as a JSON-file.

Any suggestions?

 

{"name":"MAP_SUFFIX","type":"FeatureCollection"
,"crs":{"type":"name","properties":{"name":"EPSG:25832"}}
,"features":;
{"type":"Feature","geometry":{"type":"Polygon","coordinates":;:[1,5],]1,2],]1,2],]1,2],]1,2]]]},"properties":{"filename":"ABC"}}
,{"type":"Feature","geometry":{"type":"Polygon","coordinates":;:[1,4],]1,1],]3,2],]5,2],]2,2]]]},"properties":{"filename":"DEF"}}
,{"type":"Feature","geometry":{"type":"Polygon","coordinates":;:[2,6],]5,1],]4,1],]2,3],]4,6]]]},"properties":{"filename":"GHI"}}
,{"type":"Feature","geometry":{"type":"Polygon","coordinates":;:[6,7],]4,2],]3,5],]6,7],]8,9]]]},"properties":{"filename":"JKL"}}
,{"type":"Feature","geometry":{"type":"Polygon","coordinates":;:[2,3],]1,5],]2,4],]3,2],]2,1]]]},"properties":{"filename":"MNO"}}
,{"type":"Feature","geometry":{"type":"Polygon","coordinates":;:[1,1],]1,2],]4,2],]5,4],]4,2]]]},"properties":{"filename":"PQR"}}
]}

Hi @lundse, this workflow and expressions might help you. Assuming that the attribute "_source" stores the source JSON document.

JSONTemplater: Root Expression

copy $s := fme:get-json-attribute("_source")modify (    replace json value of $s("features") with    e fme:process-features("SUB") ])return $s

JSONTemplater: SUB Expression

copy $s := fme:get-json-attribute("_source")modify (    replace json value of $s("properties")("filename") with    fme:get-attribute("Filename") || fme:get-attribute("Suffix"))return $s

 

0684Q00000ArLezQAF.png


Reply