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

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

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

Description

This 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.
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).

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")
>ZWRITE 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"