CreateJSON()

Syntax

Result = CreateJSON(#JSON [, Flags])
Description
Create new, empty JSON data. Initially, the data will contain a JSON value of type #PB_JSON_Null. The JSONValue() function can be used to access this value to change it.

Parameters

#JSON A number to identify the new JSON. #PB_Any can be used to auto-generate this number.
Flags (optional) If set to #PB_JSON_NoCase, the JSON data will be treated as case insensitive. The default is to be case sensitive.

Return value

Nonzero if the JSON data was created correctly, zero otherwise. If #PB_Any was used for the #JSON parameter then the generated number is returned on success.

Remarks

JSON is a case sensitive data format. However, in some situations, such as deserializing structures with ExtractJSONStructure() or similar commands it may be useful to treat JSON objects as case insensitive. The #PB_JSON_NoCase flag causes all member related functions to treat keys in this object as case insensitive.

Example

  If CreateJSON(0)
    Person = SetJSONObject(JSONValue(0))
    SetJSONString(AddJSONMember(Person, "FirstName"), "John")
    SetJSONString(AddJSONMember(Person, "LastName"), "Smith")
    SetJSONInteger(AddJSONMember(Person, "Age"), 42)
    
    Debug ComposeJSON(0, #PB_JSON_PrettyPrint)
  EndIf

See Also

CatchJSON(), LoadJSON(), ParseJSON(), JSONValue(), FreeJSON()

Supported OS

All

<- ComposeJSON() - Json Index - ExamineJSONMembers() ->