JSON question: I'm wanting to use Delphi's latest JSON Builder to create a JSON expression that is structured like...

JSON question: I'm wanting to use Delphi's latest JSON Builder to create a JSON expression that is structured like this:

NumStartMethods: integer
StartMethodUsed: integer
StartMethods:
Method1
param1 = something1
param2 = something2
Method2
param1 = something3
param2 = something4
param3 = something5

So we have two pairs, and an array of objects.

But I can't figure out how to get an array of objects to work!

{
"Bookmark": {
"NumStartMethods": 2,
"StartMethodUsed": 1,
"StartMethods": [
"StartMethod-1": {
"aID": "",
"aName": "foo"
},
"StartMethod-2": {
"aID": "xyz",
"aName": "bar"
"aFlag": false
}
]
}
}

This doesn't work.

Changing the square brackets to curly brackets works, but then StartMethods is just an object that contains objects, which is not what I want.

Builder
.BeginObject
.BeginObject('Bookmark')
.Add('NumStartMethods', 1)
.Add('StartMethodCalled', 1)
//.BeginArray('StartMethods')
.BeginObject('StartMethod-1')
.Add('aID', aID )
.Add('aName', aName)
.EndObject
.BeginObject('StartMethod-2')
.Add('aID', 'xyz' )
.Add('aName', aName)
.Add('aLoop', False )
.EndObject
//.EndArray
.EndObject
.EndObject;


I want to be able to access StartMethods[ StartMethodUsed ] to figure out which set of parameters are needed.

Maybe I'm just thinking about this wrong?

Comments