Hi.
The code you provide doesn't show the whole logic. I give you two examples:
1st.
Long ll_RootArray, ll_ChildArray
integer li_i, li_j
JsonGenerator lnv_JsonGenerator
lnv_JsonGenerator = Create JsonGenerator
// Create an array root item
ll_RootArray = lnv_JsonGenerator.CreateJsonArray()
for li_i = 1 to 3
// Add an array to the root Array.
ll_ChildArray = lnv_JsonGenerator.AddItemArray(ll_RootArray)
for li_j = 1 to 5
// Add an array child item
lnv_JsonGenerator.AddItemNumber(ll_ChildArray, li_j)
next
next
messagebox("", lnv_JsonGenerator.getjsonstring( ))
if isvalid(lnv_JsonGenerator) then destroy lnv_JsonGenerator
The resulting json will be:
[
[
1,
2,
3,
4,
5
],
[
1,
2,
3,
4,
5
],
[
1,
2,
3,
4,
5
]
]
2nd.
Long ll_RootArray, ll_ChildArray
integer li_i, li_j
JsonGenerator lnv_JsonGenerator
lnv_JsonGenerator = Create JsonGenerator
// Create an array root item
ll_RootArray = lnv_JsonGenerator.CreateJsonObject()
for li_i = 1 to 3
// Add an array to the root Array.
ll_ChildArray = lnv_JsonGenerator.AddItemArray(ll_RootArray, "MyNumbers" + string(li_i))
for li_j = 1 to 5
// Add an array child item
lnv_JsonGenerator.AddItemNumber(ll_ChildArray, li_j)
next
next
messagebox("", lnv_JsonGenerator.getjsonstring( ))
if isvalid(lnv_JsonGenerator) then destroy lnv_JsonGenerator
The resulting json will be:
{
"MyNumbers1": [
1,
2,
3,
4,
5
],
"MyNumbers2": [
1,
2,
3,
4,
5
],
"MyNumbers3": [
1,
2,
3,
4,
5
]
}
While I don't know what exactly you try to do, I hope that looking those examples will help you to achieve your target.
Andreas.