JSON#
NAME#
Kernel::System::JSON - the JSON wrapper lib
DESCRIPTION#
Functions for encoding perl data structures to JSON.
PUBLIC INTERFACE#
new()#
create a JSON object. Do not use it directly, instead use:
my $JSONObject = $Kernel::OM->Get('Kernel::System::JSON');
Encode()#
Encode a perl data structure to a JSON string.
my $JSONString = $JSONObject->Encode(
Data => $Data,
SortKeys => 1, # (optional) (0|1) default 0, to sort the keys of the json data
Pretty => 1, # (optional) (0|1) default 0, to pretty print
);
Decode()#
Decode a JSON string to a perl data structure.
my $PerlStructureScalar = $JSONObject->Decode(
Data => $JSONString,
);
True()#
returns a constant that can be mapped to a boolean true value in JSON rather than a string with “true”.
my $TrueConstant = $JSONObject->True();
my $TrueJS = $JSONObject->Encode(
Data => $TrueConstant,
);
This will return the string ‘true’. If you pass the perl string ‘true’ to JSON, it will return ‘“true”’ as a JavaScript string instead.
False()#
like True()
, but for a false boolean value.
_BooleansProcess()#
decode boolean values leftover from JSON decoder to simple scalar values
my $ProcessedJSON = $JSONObject->_BooleansProcess(
JSON => $JSONData,
);