All Bundles

JsonBuilder

Stack driven JSON builder

Operations

Code example:

builder := JsonBuilder->New();
money := builder->PushObject();

money->Insert("type", "usd");
money->Insert("amount", "1013");

deposits := JsonElement->New(JsonElement->JsonType->ARRAY);
deposits->Add(115);
deposits->Add(318);
deposits->Add(580);
money->Insert("deposits", deposits);

builder->Pop()->ToString()->PrintLine();

New

Constructor

New()

Add

Adds a value

method : public : Add(value:String) ~ JsonBuilder
Parameters
NameTypeDescription
valueStringvalue

Return
TypeDescription
JsonBuildertrue if successful, false otherwise

Adds a value

method : public : Add(value:Int) ~ JsonBuilder
Parameters
NameTypeDescription
valueIntvalue

Return
TypeDescription
JsonBuildertrue if successful, false otherwise

Adds a value

method : public : Add(value:Float) ~ JsonBuilder
Parameters
NameTypeDescription
valueFloatvalue

Return
TypeDescription
JsonBuildertrue if successful, false otherwise

Adds a value

method : public : Add(value:Bool) ~ JsonBuilder
Parameters
NameTypeDescription
valueBoolvalue

Return
TypeDescription
JsonBuildertrue if successful, false otherwise

Adds a value

method : public : Add(value:JsonElement) ~ JsonBuilder
Parameters
NameTypeDescription
valueJsonElementvalue

Return
TypeDescription
JsonBuildertrue if successful, false otherwise

Insert

Insert an element

method : public : Insert(name:String, value:Int) ~ JsonBuilder
Parameters
NameTypeDescription
nameStringelement name
valueIntvalue

Return
TypeDescription
JsonBuildertrue if successful, false otherwise

Insert an element

method : public : Insert(name:String, value:Float) ~ JsonBuilder
Parameters
NameTypeDescription
nameStringelement name
valueFloatvalue

Return
TypeDescription
JsonBuildertrue if successful, false otherwise

Insert an element

method : public : Insert(name:String, value:String) ~ JsonBuilder
Parameters
NameTypeDescription
nameStringelement name
valueStringvalue

Return
TypeDescription
JsonBuildertrue if successful, false otherwise

Insert an element

method : public : Insert(name:String, value:Bool) ~ JsonBuilder
Parameters
NameTypeDescription
nameStringelement name
valueBoolvalue

Return
TypeDescription
JsonBuildertrue if successful, false otherwise

Insert an element

method : public : Insert(name:String, value:JsonElement) ~ JsonBuilder
Parameters
NameTypeDescription
nameStringelement name
valueJsonElementvalue

Return
TypeDescription
JsonBuildertrue if successful, false otherwise

Pop

Pops a value

method : public : Pop() ~ JsonElement
Return
TypeDescription
JsonElementpopped element

PopAll

Pop all values

method : public : PopAll() ~ JsonElement
Return
TypeDescription
JsonElementlast popped element

PushArray

Pushes an array element on the stack

method : public : PushArray() ~ JsonBuilder

PushObject

Pushes an object element on the stack

method : public : PushObject() ~ JsonBuilder

Pushes an object element on the stack

method : public : PushObject(name:String) ~ JsonBuilder
Parameters
NameTypeDescription
nameStringobject name

Size

Size of element stack

method : public : Size() ~ Int