Skip to main content
Solved

jsontemplater - using pipe within an array

  • February 13, 2025
  • 2 replies
  • 35 views

tb09114
Supporter
Forum|alt.badge.img+22

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.

View original
Did this help you find an answer to your question?
This post is closed to further activity.
It may be a question with a best answer, an implemented idea, or just a post needing no comment.
If you have a follow-up or related question, 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+22
  • 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
Evangelist
Forum|alt.badge.img+41
  • Evangelist
  • February 17, 2025
tb09114 wrote:

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.


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