Jelix 1.6.37

jJson
in package

object which encode or decode a php variable to or from JSON

Tags
subpackage

utils

Table of Contents

$use  : mixed
decode()  : mixed
decodes a JSON string into appropriate variable
encode()  : mixed
encodes an arbitrary variable into JSON format
jJSON()  : mixed
constructs a new JSON instance

Properties

Methods

decode()

decodes a JSON string into appropriate variable

public decode(string $str) : mixed
Parameters
$str : string

JSON-formatted string

Return values
mixed

number, boolean, string, array, or object corresponding to given JSON input string. Note that decode() always returns strings in ASCII or UTF-8 format!

encode()

encodes an arbitrary variable into JSON format

public encode(mixed $var) : mixed
Parameters
$var : mixed

any number, boolean, string, array, or object to be encoded. if var is a string, note that encode() always expects it to be in ASCII or UTF-8 format!

Return values
mixed

JSON string representation of input var or an error if a problem occurs

jJSON()

constructs a new JSON instance

public jJSON(int $use) : mixed
Parameters
$use : int

object behavior flags; combine with boolean-OR possible values:

  • SERVICES_JSON_STRICT_TYPE: (default) strict convertion
  • SERVICES_JSON_LOOSE_TYPE: loose typing. "{...}" syntax creates associative arrays instead of objects in decode().
Return values
mixed

Search results