cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

TWX 8 have trouble with unterlines in JSON

Highlighted
Amethyst

TWX 8 have trouble with unterlines in JSON

Hey everyone,

I made a application with MQTT communication (receiving JSON messages) on ThingWorx 7.2.

Now I working with ThingWorx 8 and use the same application, but now I get error if the JSON messages properties include a underline ( _ ).

For example I get messages like this

{

"temp":12.16,

"brightness":9.97,

"name":"climateSensor_3",

"humidity":62.41,

"pressure":1013,

"time":1501774027515,

"CO2_concentration":599.39 }

I the datachange subscription of the sensor I do this

me.temp = newVal.temp;

me.humidity = newVal.humidity;

...

me.CO2concentration = newVal.CO2_concentration;

And I get a error: Execution error in service script [climateSensor_3 Event.DataChange:Property.MQTTValue] : Wrapped java.lang.NullPointerException Cause: null

My next step was to check every property set via logger

me.temp = newVal.temp;

logger.debug("set temp");

me.humidity = newVal.humidity;

logger.debug("set humidity");

...

me.CO2concentration = newVal.CO2_concentration;

logger.debug("set CO2_concentration");

Now I get the error before the "set CO2_concentration" is logged.

I change the

me.CO2concentration = newVal.CO2_concentration;

to

me.CO2concentration = newVal.CO2concentration;

and change the JSON messages and everything works well.

Why ThingWorx 8 not supported underline in JSON messages? Can I change this behaviar?

1 REPLY 1

Re: TWX 8 have trouble with unterlines in JSON

Hello, David.

As far as I know that hasn't changed, and the underscore should still work. I don't know MQTT, though. Let me check and find out if there have been changes made there that might explain what you're seeing.

Thank you,

-- Craig A.