dolibarr  17.0.4
Functions
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. More...
 
 _val ($val)
 Return text according to type. More...
 
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 ! More...
 
 _unval ($val)
 Return text according to type. More...
 
 utf162utf8 ($utf16)
 Convert a string from one UTF-16 char to one UTF-8 char. More...
 
 utf82utf16 ($utf8)
 Convert a string from one UTF-8 char to one UTF-16 char. More...
 

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 312 of file json.lib.php.

◆ _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 119 of file json.lib.php.

◆ 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 244 of file json.lib.php.

References 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 49 of file json.lib.php.

References 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 334 of file json.lib.php.

◆ 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 377 of file json.lib.php.