# WOBJ

Updated: 4/3/2020, 10:08:01 PM
Created: 4/3/2020, 10:08:01 PM
Last Updated By: Mike Street
Read Time: 3 minute(s)

Created At: 6/27/2017 12:13:37 AM
Updated At: 2/9/2018 9:57:49 PM
Original Doc: wobj
Original ID: 261272
Internal: No

Tags: objects rest

The WOBJ subroutine is a basic object library for consuming and creating json objects.

# COMMAND SYNTAX

CALL WOBJ(OBJECT,ACTION,NODE,VALUE,OPTIONS,RERR)
1

# SYNTAX ELEMENTS

Parameter
Description
OBJECT
Internal representation of a json object. Must be passed each time WOBJ is called.
ACTION
String specifying the action you wish to perform on the json object (see below)
NODE
Path to a node in the json object. Elements are separated by dots , standard notation for javascript objects. Null is the root node of the object.
VALUE
Value passed to SET actions or returned by GET and other actions.
OPTIONS
Options for an action (see below). Separate multiple options with @AM.
RERR
Returned errors (error level in RERR<1>, error message in RERR<2>). Error level 1 is a warning; level 2 indicates a failure; level -1 indicates the NODE is not valid.

# ACTION

Action
Description
FROMSTRING
Parse a json string into the internal representation used by WOBJ. The VALUE argument contains the json string to parse, and the OBJECT argument returns the internal representation of that object.
TOSTRING
Return a json string format from the internal object representation. The VALUE argument contains the returned json string.
GET
Returns the value of a node in the json object. If the node contains an object or an array, a json string representation of the node is returned.
SET.STRING
Set the value of a property in the json object to a string. VALUE contains the string.
SET.NUMBER
Set the value of a property in the json object to a number. VALUE must contain a valid number.
SET.BOOLEAN
Set the value of a property in the json object to a boolean. VALUE must be 'true' or 'false'.
SET.NULL
Sets the value of a property in the json object to null. VALUE is not used.
SET.OBJECT
Creates an object at specified node, or changes existing node to an object. Use this to build nested object structures. VALUE must be a json string representation of the object.
SET.ARRAY
Creates an array at specified node, or changes existing node to an array. Use this to build new arrays. VALUE must be a json string representation of the array.
DELETE
Delete a node in the json object.
LENGTH
Return the number of elements in a node. If a node contains a simple value, returns 1. If a node is not found, or contains no elements, returns 0.
TYPE
Return the type of value or object in a node. Returns NUMBER, STRING, BOOLEAN, NULL, OBJECT, ARRAY or UNDEFINED.
KEYS
Return a list of keys in a node. Keys are separated by sub-value-marks.
VERSION
Returns the version of WOBJ. Current version is 1.1.

# OPTIONS

Option
Description
PRETTIFY
Use with the TOSTRING action to add indentation and new-lines to make output more readable.
DEBUG
Use to display debug messages to the screen.

Click on this link to see a sample program on github.