Skip to main content
Solved

How to handle a booleans in the JSONTemplater


michielschram
Forum|alt.badge.img

When using the JSONTemplater I want to be able to add a real boolean to the template and not get a string.

string_booleanI made a work around by replacing the text boolean by a real boolean:

 real_booleanHas anyone figured out how to handle a boolean without the need of replacing?

Best answer by david_r

Try casting to a boolean datatype in the JSONTemplater:

{
  "istrue": xs:boolean(fme:get-attribute("istrue"))
}

The attribute should either contain an integer (0 or 1) or the string "true" / "false".

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

3 replies

david_r
Celebrity
  • Best Answer
  • March 10, 2021

Try casting to a boolean datatype in the JSONTemplater:

{
  "istrue": xs:boolean(fme:get-attribute("istrue"))
}

The attribute should either contain an integer (0 or 1) or the string "true" / "false".


michielschram
Forum|alt.badge.img

Thanks @david_r​. Works like a charm.

solution_booleanDo you have link to the documentation where this wisdom is documented?


david_r
Celebrity
  • March 10, 2021
michielschram wrote:

Thanks @david_r​. Works like a charm.

solution_booleanDo you have link to the documentation where this wisdom is documented?

I don't think it's documented in FME, you'll have to look it up in one of the many XQuery documentations online, e.g. https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqtypecon.html#wp1118764


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