Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
Result = SRP_Json(Handle, "New", Type, NewValue, Delim)

Returns

Returns 1 if successful, 0 if not.

...

ParameterDescription
Handle [OUT]Variable to receive new handle to a JSON Entity. Required.
TypeThe new entity's type: Array, Object, String, Number, or Boolean. Optional.
NewValueThe new entity's value. Optional.
DelimThe NewValue's delimiter. Optional. New in 2.1.1.

Remarks

The New service creates a new JSON entity. A JSON entity can be an object, array, string, number, boolean, or null. The type of entity created is determined by the Type parameter, which you can set to "Object", "Array", "String", "Number", "Boolean", or "Null". The NewValue parameter is also optional, but it provides a convenient way to initialize strings, numbers, and booleans. The parameter does nothing for arrays and objects due to their inherent complexityanything except objects, due to their inherent complexity.

VERSION NOTE: The ability to initialize arrays was added in version 2.1.1 and is not available prior to that. The Delim parameter allows initializing from any delimited array. If omitted, Delim defaults to @FM.

If you leave the Type parameter blank (or omit it altogether), then the type is automatically determined from the contents of NewValue. If NewValue is omitted completely, then "Object" is the type. If NewValue is included but empty, then "Null" is assumed. If NewValue contains a number, then "Number" is the type. In all other cases, the type defaults to "String".

...

Code Block
// Let's create some entities.
Success = SRP_Json(ObjectHandle, "New", "Object")
Success = SRP_Json(IntegerHandle, "New", "Number", "1234567890")
Success = SRP_Json(DecimalHandle, "New", "Number", "123456789.987654321")
Success = SRP_Json(StringHandle, "New", "String", "Hello, World!")
Success = SRP_Json(BooleanHandle, "New", "Boolean", 1)
Success = SRP_Json(ArrayHandle, "New", "Array", "1,2,3,4,5", ",")

// Don't forget to release them when we're done
SRP_Json(ArrayHandle, "Release")
SRP_Json(BooleanHandle, "Release")
SRP_Json(StringHandle, "Release")
SRP_Json(DecimalHandle, "Release")
SRP_Json(IntegerHandle, "Release")
SRP_Json(ObjectHandle, "Release")

...