DATA Methods

json()

Creates JSON object from array. If an array's field-names isn't unique only the first occurance of that field will be used.

string json( array values )

Return

Functions returns JSON object formatted string.

Parameter
Description
valuesValues to be transformed into JSON object.

Create JSON object

$DATA->json(array("field0", "field0" => "not unique", "field1" => 0, "field2" => "STRING", "field3" => array("a", "b", "c"), "field4" => $DATA->json(array("test2" => 17)), "field5" => false, "field6" => null))
RETURN: '{"field0": "","field1": 0,"field2": "STRING","field3": ["a","b","c"],"field4": "{\"test2\": 17}","field5": false,"field6": null}'