Difference between revisions of "JSON DECODE()"

From Lianjapedia
Jump to: navigation, search
(Description)
Line 10: Line 10:
 
==Description==
 
==Description==
 
The JSON_DECODE() function is used to create a dynamic array (object) from the JSON formatted string, <expC>.
 
The JSON_DECODE() function is used to create a dynamic array (object) from the JSON formatted string, <expC>.
 +
 +
The optional parameter <expC2> specified the character encoding e.g. "1252". If this is specified the text on the file will be converted to UTF8 from the encoding specified.
  
 
==Example==
 
==Example==

Revision as of 06:14, 3 September 2022

Purpose

Function to create a dynamic array (object) from a JSON formatted string

Syntax

JSON_DECODE(<expC>)

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(), 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, <expC>.

The optional parameter <expC2> specified the character encoding e.g. "1252". If this is specified the text on the file 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