kamilfb / mqtt-spy

Please use the new Eclipse Paho GitHub repo instead.
https://github.com/eclipse/paho.mqtt-spy/wiki
345 stars 68 forks source link

Message Content Chart: JSONPath: Value Expression - NumberFormatException #92

Closed NicolSpies closed 8 years ago

NicolSpies commented 8 years ago

Message content chart Series

Value expression for JSON paths that are 3 levels deep e.g. $.level1.level2.level3, returns the value encapsulated in square brackets e.g. [123.456].

This throws a java.lang.NumberFormatException: For input string: "[123.456]" Series Error

kamilfb commented 8 years ago

Hi @NicolSpies, could you attach the JSON document and the JSON expression you are testing with?

NicolSpies commented 8 years ago

json doc.txt

JSON expresssion: $.*.daily.daily

The JSON expression returns 984.567 testing the JSON and expression on this URL: https://jsonpath.curiousconcept.com/

kamilfb commented 8 years ago

The problem is in the "*" - it's a special character in JSONPath. Can you change it to a proper name?

NicolSpies commented 8 years ago

JSON special caracters are :

\b Backspace (ascii code 08) \f Form feed (ascii code 0C) \n New line \r Carriage return \t Tab \" Double quote \ Backslash character

"*" not a special character, hence the comment that the correct value was returned when tested with JSON expression validator.

I will be able to modify my IOT Node to publish only text and numeric JSON keys :smile:

kamilfb commented 8 years ago

Hi @NicolSpies - I think there are some additional JSONPath special characters: http://goessner.net/articles/JsonPath/

I agree - best to modify your IOT Node :)

NicolSpies commented 8 years ago

Apologies, you are correct, wildcard is special character. I will modify my Node. Thanks for checking.