JSON DECODE()
Contents
Purpose
Function to create a dynamic array (object) from a JSON formatted string
Syntax
JSON_DECODE(<expCM> [,<expC2>])
See Also
ACLASS(), ADDPROPERTY(), AMEMBERS(), COLUMNMETADATA(), COMPOBJ(), CREATEOBJECT(), DEFINE CLASS, DISPLAY CLASSES, DODEFAULT(), FOREACH, JSON_DECODE_FILE(), JSON_ENCODE(), LIST CLASSES, LOADOBJECT(), METADATA_DECODE(), METADATA_ENCODE(), METADATA_FINDTYPE(), NEWOBJECT(), OBJECT(), PRINT_JSON(), PRINT_HTML(), PRINT_R(), PRINT_XML(), REMOVEPROPERTY(), REQUIRE_ONCE(), SAVEOBJECT(), SET JSONBOOLEAN, SQL SELECT, SOCKET_CLOSE(), SOCKET_LASTERROR(), SOCKET_OPEN(), SOCKET_PEEK(), SOCKET_READ(), SOCKET_SERVER(), SOCKET_WRITE(), TABLEMETADATA(), WITH, XML_DECODE_FILE()
Description
The JSON_DECODE() function is used to create a dynamic array (object) from the JSON formatted string, <expCM> which may be a character type or a memo/varchar type.
The optional parameter <expC2> specifies the character encoding e.g. "1252". If this is specified the text in the string will be converted to UTF8 from the encoding specified.
Example
myobj = json_decode('{"Name":"Barry", "Company":"Lianja", "Items":["One", "two"]}') ? myobj ? myobj.name ? myobj.company ? myobj.items[1] ? myobj.items[2]
Object (refcnt=1) ( [name] => Barry [company] => Lianja [items] => Array (refcnt=1) ( [1] = One [2] = two ) ) Barry Lianja One two