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

DECODE^XLFJSON(): Convert a JSON Object into a Closed Array Reference

Reference Type: Supported, Category: JSON Conversion Functions, ICR#: 6682

Description

The DECODE^XLFJSON API converts a JSON object into a closed array reference.

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

Format

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

Input Parameters

xujson:

(required) A string or array containing a serialized JSON object.

Output Parameters

xuroot:

(required) A closed array reference for M representation of the object.

xuerr:

(optional) This contains error messages. If not defined, defaults to ^TMP(“XLFJERR”,$J).

Example

>S INJSON(1)="{""menu"":{""id"":""file"",""popup"":{""menuitem"":[{""value
"": ""New"",""onclick"":""CreateNewDoc()""},"

>S INJSON(2)="{""value"": ""Open"",""onclick"": ""OpenDoc()""},{""value"":
""Close"",""onclick"": ""CloseDoc()""}]} ,"

>S INJSON(3)="""value"":""File""}}"

>D DECODE^XLFJSON("INJSON","OUTJSON","ERRORS")

>ZW OUTJSON
OUTJSON("menu","id")="file"
OUTJSON("menu","popup","menuitem",1,"onclick")="CreateNewDoc()"
OUTJSON("menu","popup","menuitem",1,"value")="New"
OUTJSON("menu","popup","menuitem",2,"onclick")="OpenDoc()"
OUTJSON("menu","popup","menuitem",2,"value")="Open"
OUTJSON("menu","popup","menuitem",3,"onclick")="CloseDoc()"
OUTJSON("menu","popup","menuitem",3,"value")="Close"
OUTJSON("menu","value")="File"