Question

How come JSON null values are handled differently by different transformers?

  • 28 November 2021
  • 1 reply
  • 16 views

Badge +3

Hi folks,

 

While working with some JSON data, I seem to have noticed that null values are sometimes interpreted as a literal string, instead of a true <null> value (like non-existent/empty).

 

When I just tried to replicate this, it seems that different FME JSON transformers seem to handle null values in a different manner. E.g. when using a JSONFragmenter or a JSONFlattener, it seems that null values are indeed recognized as true <null> values (like non-existent/empty), but when using a JSONExtractor or an XMLXQueryExtractor (with a JSONiq query), it seems that null values are returned as a literal string.

Of course in the latter case I could add a NullAttributeMapper transformer to change the literal string 'null' to the <null> value, but this seems like a bit of a workaround (and also, how would you then distinguish between a literal string value "null" in JSON, and the true null value)

 

Is there something I'm missing, or is this a bit of a bug?

 

Kind regards,

 

Thijs

 

ps. see the below screenshot for an illustration of the case, and/or the attached workspace.

image 


1 reply

I have the same problem. 

city : null

is not the same as 

city : "null"

But JSONExtractor returns "null" and I need to check for it with another transformer and make <null> out of it. That's actually a BUG. 

Reply