JSONObject

Key-value object for JSON data.

xxml
Language::Format

Methods

MethodParametersReturnsDescription
ConstructorJSONObject^Create empty JSON object
setkey: String^, value: String^NoneSet key to value
getkey: String^String^Get value or empty string
haskey: String^Bool^Check if key exists
removekey: String^NoneRemove key
sizeInteger^Number of pairs
getIntegerkey: String^Integer^Parse value as integer
getBoolkey: String^Bool^Parse value as boolean
stringifyString^Convert to JSON string

Examples

JSONObject Usage

xxml
Instantiate Format::JSONObject^ As <obj> = Format::JSONObject::Constructor();
Run obj.set(String::Constructor("name"), String::Constructor("Alice"));
Run obj.set(String::Constructor("age"), String::Constructor("30"));

Instantiate String^ As <json> = obj.stringify();
// Result: {"name":"Alice","age":"30"}

Instantiate Integer^ As <age> = obj.getInteger(String::Constructor("age"));  // 30

See Also