Skip to main content
Solved

JSONTemplater does not set double quotes for number values


tschoppenhof
Contributor
Forum|alt.badge.img+7

My configuration in the JSONTemplater looks like this:

 

{

  "type": "Feature",

  "geometry": {

    "type": "Point",

    "coordinates": [

      fme:get-attribute("X"),

      fme:get-attribute("Y")

    ]

  },

  "properties": {

  "33064" : fme:get-attribute("33064"),

  "33085" : fme:get-attribute("33085"),

  "33103" : fme:get-attribute("33103")

  }

}

 

As result I get:

 

{ "type" : "Feature", "geometry" : { "type" : "Point", "coordinates" : [ 7.61438690276304, 47.5603635244644 ] }, "properties" : { "33064" : "", "33085" : 94328460, "33103" : "2. von B Spezmast Nr.55" } }

 

The number is not set in double quotes which results in error when I use the json string. Any ideas what could be the reason.

Best answer by takashi

Hi @tschoppenhof​ ,

You can cast a numeric value to a string value with the "xs:string" function.

Try this.

"33085" : xs:string(fme:get-attribute("33085")),

 

View original
Did this help you find an answer to your question?

3 replies

takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • Best Answer
  • October 31, 2023

Hi @tschoppenhof​ ,

You can cast a numeric value to a string value with the "xs:string" function.

Try this.

"33085" : xs:string(fme:get-attribute("33085")),

 


tschoppenhof
Contributor
Forum|alt.badge.img+7
  • Author
  • Contributor
  • October 31, 2023

Thanks takahshi, this works fine.


takashi wrote:

Hi @tschoppenhof​ ,

You can cast a numeric value to a string value with the "xs:string" function.

Try this.

"33085" : xs:string(fme:get-attribute("33085")),

 

This was helpful to guide me to all different XQuery functions, needed the xs:double.

For several other functions look at the w3 documentation

XPath and XQuery Functions and Operators 3.0 (w3.org)


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