Kernel 8.0 APIs Banner [skip navigation]
Office of Information & Technology (OIT) Banner

ENCODE^XLFJSON: Convert Closed Array or Global Reference to a JSON Object

Reference Type: Supported, Category: JSON Conversion Functions, Integration Agreement: 6682

Description

The ENCODE^XLFJSON API converts a closed array or global reference to a JSON object.

NOTE: This API was released with Kernel patch XU*8.0*680.

Format

ENCODE^XLFJSON(xuroot,xujson[,xuerr])

Input Parameters

xuroot (required) A closed array reference for M representation of the object.
xujson (required) A string or array containing a serialized JSON object.
xuerr (optional) This contains error messages. If not defined, defaults to ^TMP("XLFJERR",$J).

Output Parameters

xujson (required) A string or array containing a serialized JSON object.
xuerr (optional) This contains error messages. If not defined, defaults to ^TMP("XLFJERR",$J).

 

Example

>S Y("menu","id")="file"
>S Y("menu","popup","menuitem",1,"onclick")="CreateNewDoc()"
>S Y("menu","popup","menuitem",1,"value")="New"
>S Y("menu","popup","menuitem",2,"onclick")="OpenDoc()"
>S Y("menu","popup","menuitem",2,"value")="Open"
>S Y("menu","popup","menuitem",3,"onclick")="CloseDoc()"
>S Y("menu","popup","menuitem",3,"value")="Close"
>S Y("menu","value")="File"
>D ENCODE^XLFJSON("Y","OUTJSON","ERRORS")
>W OUTJSON(1)
{"menu":{"id":"file","popup":{"menuitem":[{"onclick":"CreateNewDoc()","value":"New"},{"onclick":"OpenDoc()","value":"Open"},{"onclick":"CloseDoc()","value":"Close"}]},"value":"File"}}