0 down vote favorite
I'm using Progress OpenEdge 11.6.1 on Windows Server 2012. I'm converting some APIs that used the REST Adapter to now use a PASOE WebHandler. The same JSON request content is giving different results between the two. In the request I pass a Progress-formatted date, such as:
The REST adapter API gets that exact value for the date and processes it successfully. However the WebHandler API gets:
The slashes appear to be escaped with backslashes, which causes an invalid date error. How can I avoid this? Do I have to write a function to strip the backslashes or is there a setting I can change to prevent the escaping?
Those are both valid. Escaping forward slashes in JSON is optional, but not required. Escaping backslashes is required.
See the sidebar for characters that can be escaped.
What are you using to decode the returned data? Are you treating it as a string or are you decoding it using the ABL JSON handling?
Could you try:
I believe that might fix your problem.
At the moment I'm not doing any decoding of the data. The request content is in a JSON object and I'm using the GetJsonText() method to extract the data I need. Is there a better way to do this?
Peter, that's exactly what's happening! I thought I might be doing something wrong but it's probably that the webhandler is not manipulating the request like the REST adapter does. I've done a simple REPLACE to get past the problem for now:
val = REPLACE(val, "\/", "/").
I'm guessing this will happen in other non-date fields too, but the date field was the only one to blow up because of the changes to the value.
There are more "escaped characters" in Json, for example: \r voor carriage return, etc
you might end up having a pretty complex replace. Take a look at my comment abount GetCharacter(). That might get you out of the woods
I switched to GetCharacter() and that fixed it. It looks like it will handle the other escaped characters too. Thanks!
Peter, I'm actually reading data. I have the webhandler request content in a JSON object and I'm reading data values with the GetJsonText() (and now GetCharacter() ) methods. If the request has this content:
then reading it like this:
val = oRequest:GetJsonText("FieldValue").
gives me "11\/30\/2016" with escaped slashes. But reading it like this:
val = oRequest:GetCharacter("FieldValue").
gives me the correct "11/30/2016". I'm using a WebResponseWriter to send back data, and that uses the Write() method.