eclipse-archived / smarthome

Eclipse SmartHome™ project
https://www.eclipse.org/smarthome/
Eclipse Public License 2.0
864 stars 782 forks source link

[Bug?] String Item content "parses" input at update #4654

Closed mebe1012 closed 6 years ago

mebe1012 commented 6 years ago

Hi,

following Situation: I initialize an array in habpanel for a dropdown list through an String Item, which contains a json string. (Its about fixed values)

Im not sure since which Version, but somehow the behaviour changed of updating a String Item with a json String via the smarthome CLI.

The following json was to be stored in a String item:

{"temperaturen": [{"temperatur": "25"}, {"temperatur": "23"}, {"temperatur": "21"}, {"temperatur": "19"}]}

I had to escape the " like this, which is understandable and the outcome of the String Item state was exact the same:

"{\"temperaturen\": [{\"temperatur\": \"25\"}, {\"temperatur\": \"23\"}, {\"temperatur\": \"21\"}, {\"temperatur\": \"19\"}]}"

BUT if I update an item with build #1099 via the smarthome CLI with the json string, now the following state is the output:

"\"temperaturen\": [{\"temperatur\": \"25\"}  {\"temperatur\": \"23\"}  {\"temperatur\": \"21\"}  {\"temperatur\": \"19\"}]"

as you can see, the curly brackets got parsed and also the commatas disappeared.

This cant be really a wanted behaviour - raw String Items shouldnt manipulate the content in any way!

If im mistaken here, please tell me so. ;-)

Cheers

PS: I create now the array as a workaround directly with angularjs. No more String Items needed.

maggu2810 commented 6 years ago

If you are using the Karaf command line to update the string item, there is a good change that it is not an Eclipse SmartHome issue but an openHAB one. Eclipse SmartHome - the framework - isn't aware of the Karaf command line handling and does not depend on Karaf at all. openHAB is a distribution / product that is based on the Eclipse SmartHome framework and uses the Karaf container for its OSGi environment. IIRC openHAB bumped the used Karaf version the last days / weeks, so perhaps this bump (the new Karaf version) causes that problem.

mebe1012 commented 6 years ago

Thanks for the hint, should have tried before to use the openhab REST API to update an item.

And indeed, the strange behaviour is gone.

Therefore it should be an issue with the Karaf CLI.

Thanks again and BR