From 3400674a8406e944a76d5456e05fdd8afe163e2c Mon Sep 17 00:00:00 2001 From: geo101 Date: Thu, 30 Jun 2016 10:54:53 -0500 Subject: [PATCH] Persistent error message in _json object There was an issue when running _json.prg and then running test1.prg afterwards. Since _json was still there, the old error message still had a value. --- json.prg | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/json.prg b/json.prg index 107776c..6be8fcf 100644 --- a/json.prg +++ b/json.prg @@ -2,11 +2,11 @@ * vfpjson * * ---------------------------------- -* Ignacio Gutirrez Torrero +* Ignacio Gutiérrez Torrero * SAIT Software Administrativo * www.sait.com.mx * +52(653)534-8800 -* Monterrey Mxico +* Monterrey México * ----------------------------------- * * JSON Library in VFP @@ -67,6 +67,7 @@ function json_encode(xExpr) public _json _json = newobject('json') endif + _json.setError("") return _json.encode(@xExpr) @@ -514,7 +515,7 @@ define class json as custom return substr(this.cJson, this.nPos, 1) function setError(cMsg) - this.cError= 'ERROR parsing JSON at Position:'+allt(str(this.nPos,6,0))+' '+cMsg + this.cError= IIF(EMPTY(cMsg), '', 'ERROR parsing JSON at Position:'+allt(str(this.nPos,6,0))+' '+cMsg) return function getError() @@ -522,18 +523,18 @@ define class json as custom function fixUnicode(cStr) - cStr = StrTran(cStr,'\u00e1','') - cStr = StrTran(cStr,'\u00e9','') - cStr = StrTran(cStr,'\u00ed','') - cStr = StrTran(cStr,'\u00f3','') - cStr = StrTran(cStr,'\u00fa','') - cStr = StrTran(cStr,'\u00c1','') - cStr = StrTran(cStr,'\u00c9','') - cStr = StrTran(cStr,'\u00cd','') - cStr = StrTran(cStr,'\u00d3','') - cStr = StrTran(cStr,'\u00da','') - cStr = StrTran(cStr,'\u00f1','') - cStr = StrTran(cStr,'\u00d1','') + cStr = StrTran(cStr,'\u00e1','á') + cStr = StrTran(cStr,'\u00e9','é') + cStr = StrTran(cStr,'\u00ed','í') + cStr = StrTran(cStr,'\u00f3','ó') + cStr = StrTran(cStr,'\u00fa','ú') + cStr = StrTran(cStr,'\u00c1','Á') + cStr = StrTran(cStr,'\u00c9','É') + cStr = StrTran(cStr,'\u00cd','Í') + cStr = StrTran(cStr,'\u00d3','Ó') + cStr = StrTran(cStr,'\u00da','Ú') + cStr = StrTran(cStr,'\u00f1','ñ') + cStr = StrTran(cStr,'\u00d1','Ñ') return cStr