dolibarr 18.0.6
json.lib.php File Reference

Functions to emulate json function when there were not activated. More...

Go to the source code of this file.

Functions

if(!function_exists( 'json_encode')) dol_json_encode ($elements)
 Implement json_encode for PHP that does not support it.
 
 _val ($val)
 Return text according to type.
 
if(!function_exists( 'json_decode')) dol_json_decode ($json, $assoc=false)
 Implement json_decode for PHP that does not support it Use json_encode and json_decode in your code !
 
 _unval ($val)
 Return text according to type.
 
 utf162utf8 ($utf16)
 Convert a string from one UTF-16 char to one UTF-8 char.
 
 utf82utf16 ($utf8)
 Convert a string from one UTF-8 char to one UTF-16 char.
 

Detailed Description

Functions to emulate json function when there were not activated.

Definition in file json.lib.php.

Function Documentation

◆ _unval()

_unval ( $val)

Return text according to type.

Parameters
string$valValue to decode
Returns
string Formated value

Definition at line 313 of file json.lib.php.

References utf162utf8().

Referenced by dol_json_decode().

◆ _val()

_val ( $val)

Return text according to type.

Parameters
mixed$valValue to show
Returns
string Formated value

Implement json_decode for PHP that does not support it

Parameters
string$jsonJson encoded to PHP Object or Array
bool$assocFalse return an object, true return an array
Returns
mixed Object or Array

Definition at line 120 of file json.lib.php.

References utf82utf16().

Referenced by dol_json_encode().

◆ dol_json_decode()

if(!function_exists('json_decode')) dol_json_decode ( $json,
$assoc = false )

Implement json_decode for PHP that does not support it Use json_encode and json_decode in your code !

Parameters
string$jsonJson encoded to PHP Object or Array
bool$assocFalse return an object, true return an array. Try to always use it with true !
Returns
mixed Object or Array or false on error
See also
json_decode()

Definition at line 245 of file json.lib.php.

References _unval(), and dol_syslog().

◆ dol_json_encode()

if(!function_exists('json_encode')) dol_json_encode ( $elements)

Implement json_encode for PHP that does not support it.

Use json_encode and json_decode in your code ! Note: We can found some special chars into a json string: Quotation mark (") = \", Backslash () = \, Slash (/) = \/, Backspace = , Form feed = \f, New line =
, Carriage return =\r, Horizontal tab = \t

Parameters
mixed$elementsPHP Object to json encode
Returns
string Json encoded string
See also
json_encode()

Definition at line 50 of file json.lib.php.

References _val(), and dol_syslog().

◆ utf162utf8()

utf162utf8 ( $utf16)

Convert a string from one UTF-16 char to one UTF-8 char.

Normally should be handled by mb_convert_encoding, but provides a slower PHP-only method for installations that lack the multibye string extension.

Parameters
string$utf16UTF-16 character
Returns
string UTF-8 character

Definition at line 335 of file json.lib.php.

Referenced by _unval().

◆ utf82utf16()

utf82utf16 ( $utf8)

Convert a string from one UTF-8 char to one UTF-16 char.

Normally should be handled by mb_convert_encoding, but provides a slower PHP-only method for installations that lack the multibye string extension.

Parameters
string$utf8UTF-8 character
Returns
string UTF-16 character

Definition at line 378 of file json.lib.php.

Referenced by _val().