jJson

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

package

jelix

subpackage

utils

Methods

decodes a JSON string into appropriate variable

decode(string $str) : mixed

Arguments

$str

string

JSON-formatted string

Response

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!

encodes an arbitrary variable into JSON format

encode(mixed $var) : mixed

Arguments

$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!

Response

mixed

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

constructs a new JSON instance

jJSON(integer $use) 

Arguments

$use

integer

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

Properties

use

use : 

Type(s)