Quantcast
Channel: West Wind Message Board Messages
Viewing all articles
Browse latest Browse all 10393

Re: JSON Special Characters?

$
0
0
Re: JSON Special Characters?
Web Connection 5.0
Re: JSON Special Characters?
Nov. 12, 2012
09:08 am
3N50JLZ4SShow this entire thread in new window
Gratar Image based on email address
From:Todd Landrum
To:Rick Strahl
That worked for me as well, but when you do it via a cursor it fails during the Deserialize with a Function argument, type, count or count is invalid. I'm doing this:

CLEARDO wwJsonSerializerCREATETABLE Test FREE (SomeText M)TEXTTO lcText NOSHOW {\rtf1\ansi\deff0\deflang1033{\fonttbl{\f0\froman\fprq2 Arial;}} {\colortbl ;\red0\green0\blue0;} \viewkind4\uc1\pard\cf1\i\f0\fs20 Aid\i0 \par \cf0\fs18 \par }ENDTEXTSELECT testAPPENDBLANKreplace SomeText WITH lcText loJson = CREATEOBJECT("wwJsonSerializer") lcJson = loJson.Serialize("cursor:Test") loDeserialized = loJson.Deserialize(lcJson) loRow = loDeserialized.Rows.Item(1) ?loRow.SomeText == Test.SomeText

The code peels off the Rows part correctly, but when it attempts to deal with the text is when the error occurs. It looks like the wwRegEx.Match function is failing to find a match, so you end up with a .f. being returned when it should be finding some text.

It's the "{" and the "}" in the lctext that is a problem. If your remove those, then it works:
<code="vfp">
TEXT TO lcText NOSHOW
{\rtf1\ansi\deff0\deflang1033{\fonttbl{\f0\froman\fprq2 Arial;}}
{\colortbl ;\red0\green0\blue0;}
\viewkind4\uc1\pard\cf1\i\f0\fs20 Aid\i0
\par \cf0\fs18
\par }
ENDTEXT
lcText = STRTRAN(lcText, "{", "QQQ")
lcText = STRTRAN(lcText, "}", "QQQ")


This should work.

I tried this:

CLEARDO wwJsonSerializerTEXTTO lcText NOSHOW {\rtf1\ansi\deff0\deflang1033{\fonttbl{\f0\froman\fprq2 Arial;}} {\colortbl ;\red0\green0\blue0;} \viewkind4\uc1\pard\cf1\i\f0\fs20 Aid\i0 blah blah blah \ul blah\ul (blah blah). \par \cf0\fs18 \par }ENDTEXT ? lcText ? ? loJson = CREATEOBJECT("wwJsonSerializer") lcJson = loJson.Serialize(lcText) ? lcJson ? ? lcDeSerialized = loJson.Deserialize(lcJson) ? lcDeserialized ? lcText == lcDeserialized

and it two-way serializes/deserializes properly with the result string equaling the original value.

+++ Rick ---


I have a memo field with rich text that I'm doing a JSON serialize with. When I deserialize that, the field is just a .t.. Other fields are working fine, other memo fields work fine, it's just the rich text data. Does JSON have some special characters that might would mess things up? The data looks something like this:

{\rtf1\ansi\deff0\deflang1033{\fonttbl{\f0\froman\fprq2 Arial;}}
{\colortbl ;\red0\green0\blue0;}
\viewkind4\uc1\pard\cf1\i\f0\fs20 Aid\i0 blah blah blah \ul blah\ul (blah blah).
\par \cf0\fs18
\par }





Viewing all articles
Browse latest Browse all 10393

Trending Articles