1

Closed

nfjson doesn't unescape special characters

description

Hi,

when I use nfjsoncreate special characters (like for example double quotes) are correctly escaped, so the output for the following code:
pair = CREATEOBJECT("empty")
addproperty(pair , "context", '"hello"')

json = nfjsoncreate(pair)
is correctly
{"context":"\"hello\""}
However if we take this output and try to rebuild the original object, the double quotes are not unescaped. To be more clear the output for the following code:
pair = CREATEOBJECT("empty")
addproperty(pair , "context", '"hello"')

json = nfjsoncreate(pair)

deserialobj = nfjsonread(json)
?nfjsoncreate(deserialobj)
is
{"context":"\\\"hello\\"}
Maybe there is a problem with function unescapecontrolc from nfjsonread?
Closed Jan 11 at 4:44 PM by mplazac
Fixed on 2017/01/11 release.

comments

mplazac wrote Jan 11 at 4:33 PM

Thanks for reporting the issue.

Please download the latest version and check the notes.

Marco

wrote Jan 11 at 4:44 PM

adelbene wrote Jan 11 at 5:04 PM

Thank you VERY much!

adelbene wrote Jan 11 at 5:26 PM

One more thing. nfjsonread should unescape special characters. I mean the following code:
deserialobj = nfjsonread('{"foo": "string \"with\" quote"}')
?deserialobj.foo
should output 'string "with" quote' while at the moment it keeps the slash character (ie: 'string \"with\" quote')

mplazac wrote Jan 11 at 7:44 PM

Hi adelbene, I re-checked and it works properly.

Maybe you are running the old fxp?.

Don't hesitate on reporting any other issue.

adelbene wrote Jan 11 at 9:10 PM

Yep! Sorry, my bad. You are right, everything works fine now.

Thank you again. I really appreciate your help!

adelbene wrote Jan 12 at 10:47 AM

Hi,

I just noted one thing that looks weird to me, but maybe it's a problem with my VFP environment. As I said now everything works fine, but only if I compile my code to exe and run it. If instead I try to run my code from VFP I get the behaviour I told you in the last post ( it keeps the slash character: 'string \"with\" quote').
Was it meant to behave like this or (more likely) is a problem with my dev environment?

Thank you.

adelbene wrote Jan 12 at 5:02 PM

Forget my last post. I had a 'SET EXACT ON' that ruined everything :)

mplazac wrote Jan 12 at 7:23 PM

Hi Adelbene, thanks for letting me know.. I just passed by that possibility. I'll check th code and make the adjustments to make the code run independently from the user settings.

mplazac wrote Jan 13 at 1:05 PM

updated release now works with set exact on/off

adelbene wrote Jan 13 at 1:50 PM

thank you again!