Skip to main content
Solved

Writing a List to JSON Array


sieblist
Participant
Forum|alt.badge.img

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"]

 

}

 

]

 

Best answer by david_r

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"]}]
View original
Did this help you find an answer to your question?

6 replies

danilo_fme
Evangelist
Forum|alt.badge.img+44
  • Evangelist
  • May 28, 2019

Hi @sieblist

After the transformer ListBuilder use the ListConcatenator.

And the transformer JSONTemplater to create your template:

 

 

Thanks,

Danilo


danilo_fme
Evangelist
Forum|alt.badge.img+44
  • Evangelist
  • May 28, 2019

Please, see this Workspace template FMWT.

I changed the transformer JSONTemplater:

 

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

 

Danilo


david_r
Evangelist
  • Best Answer
  • May 28, 2019

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"]}]

david_r
Evangelist
  • May 28, 2019
david_r wrote:

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


danilo_fme
Evangelist
Forum|alt.badge.img+44
  • Evangelist
  • May 28, 2019
david_r wrote:

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

sieblist
Participant
Forum|alt.badge.img
  • Author
  • Participant
  • May 29, 2019

 

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

Greetings Steffen


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings