Skip to content

Commit ed6f7b9

Browse files
committed
ObjectToJSON() bug fixed
1 parent 5eae179 commit ed6f7b9

File tree

3 files changed

+35
-6
lines changed

3 files changed

+35
-6
lines changed

Diff for: jsonfox.app

310 Bytes
Binary file not shown.

Diff for: src/jsonclass.prg

+29-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ define class JSONClass as session
44
LastErrorText = ""
55
lError = .f.
66
lShowErrors = .t.
7-
version = "9.9"
7+
version = "9.10"
88
hidden lInternal
99
hidden lTablePrompt
1010
Dimension aCustomArray[1]
@@ -56,7 +56,33 @@ define class JSONClass as session
5656
Else
5757
return loJSONObj
5858
EndIf
59-
endfunc
59+
ENDFUNC
60+
61+
* tokenize
62+
FUNCTION dumpTokens
63+
lparameters tcJsonStr as memo, tcOutput as string
64+
try
65+
this.ResetError()
66+
local lexer
67+
if this.NETScanner
68+
lexer = createobject("NetScanner", tcJsonStr)
69+
else
70+
lexer = createobject("Tokenizer", tcJsonStr)
71+
endif
72+
Local laTokens
73+
laTokens = lexer.scanTokens()
74+
IF FILE(tcOutput)
75+
DELETE FILE (tcOutput)
76+
ENDIF
77+
FOR EACH loToken IN laTokens
78+
STRTOFILE(tokenStr(loToken), tcOutput, 1)
79+
ENDFOR
80+
catch to loEx
81+
this.ShowExceptionError(loEx)
82+
finally
83+
release lexer, laTokens
84+
ENDTRY
85+
ENDFUNC
6086

6187
* Stringify
6288
function Stringify as memo
@@ -292,7 +318,7 @@ define class JSONClass as session
292318
return lcOutput
293319
endfunc
294320
* tokenize
295-
function dumpTokens
321+
function dumpTokens2
296322
lparameters tcJsonStr as memo
297323
try
298324
this.ResetError()

Diff for: src/objecttojson.prg

+6-3
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ define class ObjectToJSON as session
4646
for k = 1 to alen(tValue)
4747
lcArray = lcArray + iif(len(lcArray) > 1, ',', '')
4848
try
49+
local array laLista[1]
4950
*local array aLista(alen(tValue[k]))
50-
=acopy(tValue[k], aLista)
51+
=acopy(tValue[k], laLista)
5152
lcArray = lcArray + this.AnyToJson(@aLista)
5253
catch
5354
lcArray = lcArray + this.AnyToJson(tValue[k])
@@ -67,7 +68,8 @@ define class ObjectToJSON as session
6768
lcArray = lcArray + ','
6869
endif
6970
try
70-
=acopy(tValue[k, j], aLista)
71+
local array laLista[1]
72+
=acopy(tValue[k, j], laLista)
7173
lcArray = lcArray + this.AnyToJson(@aLista)
7274
catch
7375
lcArray = lcArray + this.AnyToJson(tValue[k, j])
@@ -91,7 +93,8 @@ define class ObjectToJSON as session
9193
lcJSONStr = lcJSONStr + iif(len(lcJSONStr) > 1, ',', '') + '"' + lcProp + '":'
9294
try
9395
*local array aCopia(alen(tValue. &gaMembers[j]))
94-
=acopy(tValue. &gaMembers[j], aCopia)
96+
local array laLista[1]
97+
=acopy(tValue. &gaMembers[j], laLista)
9598
lcJSONStr = lcJSONStr + this.AnyToJson(@aCopia)
9699
catch
97100
try

0 commit comments

Comments
 (0)