Skip to main content
Solved

Writing a List to JSON Array

  • May 28, 2019
  • 6 replies
  • 693 views

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"]}]
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

6 replies

danilo_fme
Celebrity
Forum|alt.badge.img+51
  • Celebrity
  • 2077 replies
  • May 28, 2019

Hi @sieblist

After the transformer ListBuilder use the ListConcatenator.

And the transformer JSONTemplater to create your template:

 

 

Thanks,

Danilo


danilo_fme
Celebrity
Forum|alt.badge.img+51
  • Celebrity
  • 2077 replies
  • May 28, 2019

Please, see this Workspace template FMWT.

I changed the transformer JSONTemplater:

 

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

 

Danilo


david_r
Celebrity
  • 8394 replies
  • 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
Celebrity
  • 8394 replies
  • 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"]}]

Here's the complete workspace: json_list.fmwt


danilo_fme
Celebrity
Forum|alt.badge.img+51
  • Celebrity
  • 2077 replies
  • 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"]}]
Thank you for endorsing the response

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

 

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

Greetings Steffen