Functions available from D2000 V12.2.
JSON format manipulation functions allows to create, read, write and delete JSON objects. Function names are created by the prefix %JSON_.
When adding invalid value (e.g. %JSON_ObjectSetValue), value in JSON is stored as null. When reading null value from JSON (e.g. %JSON_ObjectGetValue), value is interpreted as invalid value.
Every handle to JSON object or array must be released by calling %JSON_FreeObjectHandle or %JSON_FreeArrayHandle.
Handle remain valid also after deleting of child object or array (e.g. %JSON_ArrayRemoveItem) pointed to by the handle. Similarly when removed parent object or array, handle pointed to child remains valid.
Example:
INT _obj INT _clientInfo TEXT _d2version _obj := %JSON_ObjectFromString(ModuleInfo) _clientInfo := %JSON_ObjectGetObject(_obj, "client_data") %JSON_FreeObjectHandle(_obj) ; release handle to _obj, _clientInfo is still valid handle _d2version := %JSON_ObjectGetValue(_clientInfo, "d2000_version") LOG "D2000 version", _d2version PRIORITY _LOG_PRTY_INFO %JSON_FreeObjectHandle(_clientInfo) ; finally release _clientInfo handle
There is created JSON object from ModuleInfo variable, then we get value from object and this value is written into monitoring database.
%JSON file manipulation functions:
- %JSON_CreateObject
- %JSON_CreateArray
- %JSON_FreeObjectHandle
- %JSON_FreeArrayHandle
- %JSON_ObjectSetValue
- %JSON_ObjectSetArray
- %JSON_ObjectSetObject
- %JSON_ArraySetValue
- %JSON_ArraySetArray
- %JSON_ArraySetObject
- %JSON_ArrayAppendValue
- %JSON_ArrayAppendArray
- %JSON_ArrayAppendObject
- %JSON_ObjectGetValue
- %JSON_ObjectGetArray
- %JSON_ObjectGetObject
- %JSON_ArrayGetValue
- %JSON_ArrayGetArray
- %JSON_ArrayGetObject
- %JSON_ObjectIsValue
- %JSON_ObjectIsArray
- %JSON_ObjectIsObject
- %JSON_ArrayIsValue
- %JSON_ArrayIsArray
- %JSON_ArrayIsObject
- %JSON_ArrayGetLength
- %JSON_ArraySetLength
- %JSON_ArrayClear
- %JSON_ArrayRemoveItem
- %JSON_ObjectGetFieldsCount
- %JSON_ObjectGetFieldName
- %JSON_ObjectHasField
- %JSON_ObjectClear
- %JSON_ObjectRemoveField
- %JSON_ObjectToString
- %JSON_ObjectFromString
- %JSON_ArrayToString
- %JSON_ArrayFromString
Related pages:
0 komentárov