Escape character and JsonObject Question/Error - Forum - OpenEdge Development - Progress Community

Escape character and JsonObject Question/Error

 Forum

Escape character and JsonObject Question/Error

This question is answered

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!

Verified Answer
  • 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.

  • 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
  • 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.

  • 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.
     
     
  • Thanks Robin and Peter for your quick responses!