The JsonAppend function adds a value to the array.
int @JsonAppend(string objectId, object value);
int @JsonAppend(string objectId, object value, string dataType);
Parameters
string objectId : Target JSON array ID
object value : JSON object ID to add
string dataType : The data type of the value, "string" when not filled in
"string" : string
"int", "long" : integer
"float", "double", "decimal" : real value
"bool" : boolean value
"datetime" : datetime
"null" : null
Return Values
1 : Sucees
0 : Failure
Example 1)
string jsonArray = @JsonStructNew("[]");
// Add different
types of data
@JsonAppend(jsonArray, "ABC", "string");
@JsonAppend(jsonArray, 123, "int");
@JsonAppend(jsonArray, 45.67, "double");
@JsonAppend(jsonArray, true,
"bool");
Add as date format
@JsonAppend(jsonArray, DateTime.Now.ToString(),
"datetime:yyyy-MM-dd");
// Result : ["ABC", 123, 45.67, true, "2025-03-19"]
string result = @JsonToString(jsonArray);
Example 2)
// 1. JSON Object Creation
string jsonObj = @JsonStructNew("{}");
// 2. Set properties
@JsonSet(jsonObj, "name", "John", "string");
@JsonSet(jsonObj, "age", 30,
"int");
@JsonSet(jsonObj, "isActive", true, "bool");
// 3. Create nested objects
string addressObj = @JsonStructNew("{}");
@JsonSet(addressObj, "city", "Seoul",
"string");
@JsonSet(addressObj, "zipcode", "12345", "string");
// 4. Add nested objects
@JsonSet(jsonObj, "address", addressObj);
// 5. Create an array
string phoneArray = @JsonStructNew("[]");
@JsonAppend(phoneArray,
"010-1234-5678", "string");
@JsonAppend(phoneArray, "02-123-4567", "string");
// 6. Add an array
@JsonSet(jsonObj, "phoneNumbers", phoneArray);
// 7. Convert to JSON String
string jsonString = @JsonToString(jsonObj);
@MessageBox(jsonString, "jsonString", MB_OK);
// 8. Memory
Cleanup
@JsonClear(jsonObj);
@JsonClear(addressObj);
@JsonClear(phoneArray);
Version information
Supported Version: 10.3.6.25 or later
Related Helps)
JsonTemplateReplacePlaceholder