Hi all
This is on Craig Boyd's Sweet Potato Software site (https://tinyurl.com/ybk97s97) but the download link is coming up 404. Any ideas where I can get hold of it? Or alternative VFP options to handle JSON? I have tried the following from various sources (e.g. VFPX, GitHub, CodePlex) : nfJson-master (Marco Plaza), vfpJson-master (Ignacio Gutiérrez Torrero), qdfoxjson (Victor Espina)
but none of them can decode JSON strings like this:
"{"code":" ERROR","message":"Message ","errors":[{"field1":"FIELD","value":"VALUE"}]}"
They all appear to stumble because of the additional JSON between the [] brackets. I could StrExtract the string between the [] and decode that separately but I would rather find something that can handle this directly. Failing that I'll have to "roll my own".
Thanks
Paul Newton
FoxInCloud has a FOSS function doing that, provided you remove the ‘\’ escape characters:
o = uValueJS(Strtran('{"code":" ERROR","message":"Message ","errors":[{"field1":"FIELD","value":"VALUE"}]}', '"', '"'))
https://github.com/FoxInCloud/FoxInCloud-AB https://github.com/FoxInCloud/FoxInCloud-AB
Thierry Nivelet FoxinCloud Give your VFP app a new life in the cloud http://foxincloud.com/
Le 16 nov. 2018 à 12:49, Paul Newton Paul.Newton@pegasus.co.uk a écrit :
Hi all
This is on Craig Boyd's Sweet Potato Software site (https://tinyurl.com/ybk97s97) but the download link is coming up 404. Any ideas where I can get hold of it? Or alternative VFP options to handle JSON? I have tried the following from various sources (e.g. VFPX, GitHub, CodePlex) : nfJson-master (Marco Plaza), vfpJson-master (Ignacio Gutiérrez Torrero), qdfoxjson (Victor Espina)
but none of them can decode JSON strings like this:
"{"code":" ERROR","message":"Message ","errors":[{"field1":"FIELD","value":"VALUE"}]}"
They all appear to stumble because of the additional JSON between the [] brackets. I could StrExtract the string between the [] and decode that separately but I would rather find something that can handle this directly. Failing that I'll have to "roll my own".
Thanks
Paul Newton
[excessive quoting removed by server]
oops, sorry, it’s in the Web layer, not in the public layer
if you’re stuck and no dependency to the Web layer, I can move it to the public layer AB
just let me know
Thierry Nivelet
Le 16 nov. 2018 à 13:29, Thierry Nivelet tnivelet@foxincloud.com a écrit :
FoxInCloud has a FOSS function doing that, provided you remove the ‘\’ escape characters:
o = uValueJS(Strtran('{"code":" ERROR","message":"Message ","errors":[{"field1":"FIELD","value":"VALUE"}]}', '"', '"'))
https://github.com/FoxInCloud/FoxInCloud-AB https://github.com/FoxInCloud/FoxInCloud-AB <https://github.com/FoxInCloud/FoxInCloud-AB https://github.com/FoxInCloud/FoxInCloud-AB>
Thierry Nivelet FoxinCloud Give your VFP app a new life in the cloud http://foxincloud.com/ http://foxincloud.com/
Le 16 nov. 2018 à 12:49, Paul Newton Paul.Newton@pegasus.co.uk a écrit :
Hi all
This is on Craig Boyd's Sweet Potato Software site (https://tinyurl.com/ybk97s97) but the download link is coming up 404. Any ideas where I can get hold of it? Or alternative VFP options to handle JSON? I have tried the following from various sources (e.g. VFPX, GitHub, CodePlex) : nfJson-master (Marco Plaza), vfpJson-master (Ignacio Gutiérrez Torrero), qdfoxjson (Victor Espina)
but none of them can decode JSON strings like this:
"{"code":" ERROR","message":"Message ","errors":[{"field1":"FIELD","value":"VALUE"}]}"
They all appear to stumble because of the additional JSON between the [] brackets. I could StrExtract the string between the [] and decode that separately but I would rather find something that can handle this directly. Failing that I'll have to "roll my own".
Thanks
Paul Newton
[excessive quoting removed by server]
Thanks Thierry - I'll look into it
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Thierry Nivelet Sent: 16 November 2018 12:29 To: profoxtech@leafe.com Subject: Re: JSON for Visual FoxPro
Sent by an external sender ------------------------------
FoxInCloud has a FOSS function doing that, provided you remove the ‘\’ escape characters:
o = uValueJS(Strtran('{"code":" ERROR","message":"Message ","errors":[{"field1":"FIELD","value":"VALUE"}]}', '"', '"'))
https://github.com/FoxInCloud/FoxInCloud-AB https://github.com/FoxInCloud/FoxInCloud-AB
Thierry Nivelet FoxinCloud Give your VFP app a new life in the cloud http://foxincloud.com/
Le 16 nov. 2018 à 12:49, Paul Newton Paul.Newton@pegasus.co.uk a écrit :
Hi all
This is on Craig Boyd's Sweet Potato Software site (https://tinyurl.com/ybk97s97) but the download link is coming up 404. Any ideas where I can get hold of it? Or alternative VFP options to handle JSON? I have tried the following from various sources (e.g. VFPX, GitHub, CodePlex) : nfJson-master (Marco Plaza), vfpJson-master (Ignacio Gutiérrez Torrero), qdfoxjson (Victor Espina)
but none of them can decode JSON strings like this:
"{"code":" ERROR","message":"Message ","errors":[{"field1":"FIELD","value":"VALUE"}]}"
They all appear to stumble because of the additional JSON between the [] brackets. I could StrExtract the string between the [] and decode that separately but I would rather find something that can handle this directly. Failing that I'll have to "roll my own".
Thanks
Paul Newton
[excessive quoting removed by server]
_______________________________________________ Post Messages to: ProFox@leafe.com Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech Searchable Archive: http://leafe.com/archives/search/profox This message: http://leafe.com/archives/byMID/profox/02DD95F0-95DF-4B04-8705-088474E613EB@... ** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious. Report [OT] Abuse: http://leafe.com/reportAbuse/02DD95F0-95DF-4B04-8705-088474E613EB@foxincloud...
nfjson seems okay with it if you strip out the escaping on the double quotes.
x = '{"code":" ERROR","message":"Message ","errors":[{"field1":"FIELD","value":"VALUE"}]}' y=chrtran(x,"","") oJson = nfJsonRead(y)
Thanks Alan - I'll try that on some real JSON I am working with
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Alan Bourke Sent: 16 November 2018 12:33 To: profoxtech@leafe.com Subject: Re: JSON for Visual FoxPro
Sent by an external sender ------------------------------
nfjson seems okay with it if you strip out the escaping on the double quotes.
x = '{"code":" ERROR","message":"Message ","errors":[{"field1":"FIELD","value":"VALUE"}]}' y=chrtran(x,"","") oJson = nfJsonRead(y)
TBF I don't think all those double quotes should be escaped anyway. IIRC it's only if you're including string data and the string data has double quotes in it.
{ "string1":"This value legitimately contains "some quotes""} }
Alan
The problem occurred when I was working in .NET - hence the need for escaping the double quotes
Paul -----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Alan Bourke Sent: 16 November 2018 13:45 To: profoxtech@leafe.com Subject: Re: JSON for Visual FoxPro
Sent by an external sender ------------------------------
TBF I don't think all those double quotes should be escaped anyway. IIRC it's only if you're including string data and the string data has double quotes in it.
{ "string1":"This value legitimately contains "some quotes""} }
-- Alan Bourke alanpbourke (at) fastmail (dot) fm
[excessive quoting removed by server]
I use a the Chilkat ActiveX control for many things. The Json part of the control is free for use. http://chilkatsoft.com/
He has VFP examples on the website. And the times I've had problems, he was quick to respond.
LOCAL loArray as Chilkat_v9_5_0.IChilkatJsonArray LOCAL loObject as Chilkat_v9_5_0.IChilkatJsonObject loObject = CreateObject('Chilkat_9_5_0.JsonObject') json = CHRTRAN('{"code":" ERROR","message":"Message ","errors":[{"field1":"FIELD","value":"VALUE"}]}',"","") ?'--' loObject.load(json) ?loObject.stringof("code") loArray = loObject.arrayof("errors") ?loArray.ObjectAt(0).StringOf("field1") ?loArray.ObjectAt(0).StringOf("value") ?loObject.emit()
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Paul Newton Sent: Friday, November 16, 2018 8:56 AM To: profoxtech@leafe.com Subject: RE: JSON for Visual FoxPro
Alan
The problem occurred when I was working in .NET - hence the need for escaping the double quotes
Paul -----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Alan Bourke Sent: 16 November 2018 13:45 To: profoxtech@leafe.com Subject: Re: JSON for Visual FoxPro
Sent by an external sender ------------------------------
TBF I don't think all those double quotes should be escaped anyway. IIRC it's only if you're including string data and the string data has double quotes in it.
{ "string1":"This value legitimately contains "some quotes""} }
-- Alan Bourke alanpbourke (at) fastmail (dot) fm
[excessive quoting removed by server]
That function decodes unicode entities in case it can be of help -----------------------------------------------------------------
FUNCTION _FFWK_DecodeUnicodeEntities LPARAMETERS tcString LOCAL lcResultString, lnPosicion, lcChar, lcTokenString m.lcResultString = m.tcString DO WHILE .T. m.lnPosicion = AT( "\u", m.lcResultString, 1 ) IF m.lnPosicion = 0 EXIT ENDIF m.lcTokenString = SUBSTR( m.lcResultString, m.lnPosicion, 6 ) IF LOWER(m.lcTokenString) = "\u20ac" m.lcChar = "€" ELSE TRY m.lcChar = CHR( EVALUATE( "0x" + SUBSTR( m.lcResultString, m.lnPosicion + 2, 4) ) ) CATCH m.lcChar = "" ENDTRY ENDIF m.lcResultString = STRTRAN( m.lcResultString , m.lcTokenString, m.lcChar ) ENDDO RETURN m.lcResultString ENDFUNC
------------------------------------ Jose Enrique Llopis ------------------------------------
-----Mensaje original----- De: ProFox [mailto:profox-bounces@leafe.com] En nombre de Paul Newton Enviado el: viernes, 16 de noviembre de 2018 12:50 Para: 'profox@leafe.com' Asunto: JSON for Visual FoxPro
Hi all
This is on Craig Boyd's Sweet Potato Software site (https://tinyurl.com/ybk97s97) but the download link is coming up 404. Any ideas where I can get hold of it? Or alternative VFP options to handle JSON? I have tried the following from various sources (e.g. VFPX, GitHub, CodePlex) : nfJson-master (Marco Plaza), vfpJson-master (Ignacio Gutiérrez Torrero), qdfoxjson (Victor Espina)
but none of them can decode JSON strings like this:
"{"code":" ERROR","message":"Message ","errors":[{"field1":"FIELD","value":"VALUE"}]}"
They all appear to stumble because of the additional JSON between the [] brackets. I could StrExtract the string between the [] and decode that separately but I would rather find something that can handle this directly. Failing that I'll have to "roll my own".
Thanks
Paul Newton
[excessive quoting removed by server]