Solved

How to handle a booleans in the JSONTemplater

  • 10 March 2021
  • 3 replies
  • 11 views

Badge

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?

icon

Best answer by david_r 10 March 2021, 11:06

View original

3 replies

Userlevel 4

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".

Badge

Thanks @david_r​. Works like a charm.

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

Userlevel 4

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

Reply