Escape character and JsonObject Question/Error

Posted by xjg on 06-Nov-2017 13:28

Hello,

I've recently started using the JsonObject class available in progress and I've realized the following:

I try to set a character value of a given property that contains a slash. E.g: myJsonObject:Set("MyProperty", "abcd/1234"),

If I later print the JsonObject I see that the value set it's actually "abcd\/1234". I've tried to anticipate this issue by setting the scape character my self by running myJsonObject:Set("MyProperty", "abcd\/1234") instead. The property however, is set to "abcd\/1234".

Do you know what I could use as a work-around to set the value properly?

Thanks in advance for your inputs!

Posted by Robin Brown on 06-Nov-2017 13:42

The '/' character needs to be escaped in the JSON string.  Look at www.json.org.  The string will be un-escaped by the parser when extracting the property's value.

Posted by Peter Judge on 06-Nov-2017 13:42

This (or a similar question) was asked on Communities a little while ago. The answer given was that that’s what the serializers do. There’s no harm I it (other JSON readers recognise it as an escape). The only way to do it would be to write your own serializer.
 
 

All Replies

Posted by Robin Brown on 06-Nov-2017 13:42

The '/' character needs to be escaped in the JSON string.  Look at www.json.org.  The string will be un-escaped by the parser when extracting the property's value.

Posted by Peter Judge on 06-Nov-2017 13:42

This (or a similar question) was asked on Communities a little while ago. The answer given was that that’s what the serializers do. There’s no harm I it (other JSON readers recognise it as an escape). The only way to do it would be to write your own serializer.
 
 

Posted by xjg on 06-Nov-2017 13:47

Thanks Robin and Peter for your quick responses!

This thread is closed