Solved

Writing a List to JSON Array


I want to output a feature with a list (CITY) into a correct JSON array as described below. However, that does not work. Can somebody help me with it?

 

[

 

{

 

"CITY" : ["Frankfurt","Hamburg","Berlin"]

 

}

 

]

 

icon

Best answer by david_r 28 May 2019, 17:21

View original

6 replies

Userlevel 4
Badge +30

Hi @sieblist

After the transformer ListBuilder use the ListConcatenator.

And the transformer JSONTemplater to create your template:

 

 

Thanks,

Danilo

Userlevel 4
Badge +30

Please, see this Workspace template FMWT.

I changed the transformer JSONTemplater:

 

Thanks, - 27541-problem-none2json-danilo.fmw

 

Danilo

Userlevel 4

There's probably no need to use the JSONTemplater here, it comes with it's own set of challenges.

After the ListBuilder, insert a ListRenamer to make the list correspond to what the JSON writer expects:

0684Q00000ArLanQAF.png

This will rename city_list{}.CITY to just CITY{}

Result:

[{"CITY":["Frankfurt","Hamburg","Berlin"]}]
Userlevel 4

There's probably no need to use the JSONTemplater here, it comes with it's own set of challenges.

After the ListBuilder, insert a ListRenamer to make the list correspond to what the JSON writer expects:

0684Q00000ArLanQAF.png

This will rename city_list{}.CITY to just CITY{}

Result:

[{"CITY":["Frankfurt","Hamburg","Berlin"]}]

Here's the complete workspace: json_list.fmwt

Userlevel 4
Badge +30

There's probably no need to use the JSONTemplater here, it comes with it's own set of challenges.

After the ListBuilder, insert a ListRenamer to make the list correspond to what the JSON writer expects:

0684Q00000ArLanQAF.png

This will rename city_list{}.CITY to just CITY{}

Result:

[{"CITY":["Frankfurt","Hamburg","Berlin"]}]
Thank you for endorsing the response

 

Hi, thanks for your help ... especially @david_r whose tip has brought the desired result.

Greetings Steffen

Reply