Skip to main content
Solved

jsontemplater - using pipe within an array

  • February 13, 2025
  • 2 replies
  • 70 views

tb09114
Supporter
Forum|alt.badge.img+27

I want to build a flat JSON array using the jsontemplater. I try to use this example to understand the syntax but using the pipe character does not go well.

Starting with a simple creator for the root object and sending the actual information to the ‘ADDRESSES’ sub template.
 

I try to define the root template as 

[|
fme:process-features("ADDRESSES")
|]

and the sub template as

{
"ID": fme:get-attribute("Site_ID"),
"Address": fme:get-attribute("Address")
}

Taking it from the linked example the pipe character is needed to separate the array items by commas.

My translation log return the following warnings, and error message

JSONTemplater (XMLTemplaterFactory): The following error occurred near line 1, column 3 of the query:
JSONTemplater (XMLTemplaterFactory): invalid expression: syntax error, unexpected "|"
JSONTemplater (XMLTemplaterFactory): An error occurred while parsing the ROOT template
 

How do I use the jsontemplater to create some flat JSON array structured as

 

[
{
"ID": "Site_ID",
"Address": "Address"
},
{
"ID": "Site_ID",
"Address": "Address"
}
]

 

Best answer by tb09114

Okay, I found it out.

For the flat array, there is no need to use the pipe |. Simply delete the pipes from the root template and the array is created as expected.

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.

2 replies

tb09114
Supporter
Forum|alt.badge.img+27
  • Author
  • Supporter
  • Best Answer
  • February 15, 2025

Okay, I found it out.

For the flat array, there is no need to use the pipe |. Simply delete the pipes from the root template and the array is created as expected.


danilo_fme
Celebrity
Forum|alt.badge.img+51
  • Celebrity
  • February 17, 2025

Okay, I found it out.

For the flat array, there is no need to use the pipe |. Simply delete the pipes from the root template and the array is created as expected.

Hi ​@tb09114 

 

Yes, you are correct.