Page History
...
Code Block |
---|
// Adding a member to the current object SRP_JsonX(MemberName, Value, Hint) // Adding a value to the current array SRP_JsonX(Value, Hint) // Starting a new object or array in the current object SRP_JsonX(MemberName, Opener) // Starting a new object or array in the current array SRP_JsonX(Opener) // If closing an object or array SRP_JsonX(Closer) |
Returns
1 if successful, 0 if there was an error.
Parameters
Parameter | Description |
---|---|
MemberName | The name of the new object member. |
Value | The new value. Omit to pass null. |
Hint | Forces the value into a json type. Can be "Bool", "Null", or "String". Optional. |
Opener | Starts a new object or array. Can be "{" or "[". |
Closer | Closes the current element. Can be "}" or "]". |
Remarks
SRP_JsonX is a dynamic routine that interprets its parameter based on the current state of the document. The actual parameter names are strange, so the SRP Editor tooltip won't always be of use. There are three general use cases:
...
The Hint parameter can be used to force the value into a specific json type. Use "Bool" to force the value to be true or false. Use "Null" to ignore the given value and just use null as the value. Use "String" to force the value into a string, which is useful when you want an OI number to be surrounded by quotes in the json itself.
Examples
Code Block |
---|
$insert SRPJSONX SRP_JsonX_Begin('MyDocument', '{') SRP_JsonX('employees', '[') SRP_JsonX('{') SRP_JsonX('firstname', 'John') SRP_JsonX('lastname', 'Doe') SRP_JsonX('age', 21) SRP_JsonX('}') SRP_JsonX('{') SRP_JsonX('firstname', 'Anna') SRP_JsonX('lastname', 'Smith') SRP_JsonX('age', 32) SRP_JsonX('}') SRP_JsonX('{"firstname":"Peter", "lastname":"Jones", "age":43}') SRP_JsonX(']') SRP_JsonX('count', 4) SRP_JsonX('active', 1, 'Bool') SRP_JsonX('alwaysnull') SRP_JsonX('alwaysstring', 4.321, 'String') Json = SRP_JsonX_End('Pretty') |
...