Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
|
Static Public Member Functions | |
static | decode ($encodedValue, $objectDecodeType=Zend_Json::TYPE_ARRAY) |
static | encode ($valueToEncode, $cycleCheck=false, $options=array()) |
static | fromXml ($xmlStringContents, $ignoreXmlAttributes=true) |
static | prettyPrint ($json, $options=array()) |
Data Fields | |
const | TYPE_ARRAY = 1 |
const | TYPE_OBJECT = 0 |
Static Public Attributes | |
static | $maxRecursionDepthAllowed =25 |
static | $useBuiltinEncoderDecoder = false |
Static Protected Member Functions | |
static | _recursiveJsonExprFinder (&$value, array &$javascriptExpressions, $currentKey=null) |
static | _getXmlValue ($simpleXmlElementObject) |
static | _processXml ($simpleXmlElementObject, $ignoreXmlAttributes, $recursionDepth=0) |
|
staticprotected |
Return the value of an XML attribute text or the text between the XML tags
In order to allow Zend_Json_Expr from xml, we check if the node matchs the pattern that try to detect if it is a new Zend_Json_Expr if it matches, we return a new Zend_Json_Expr instead of a text node
SimpleXMLElement | $simpleXmlElementObject |
Definition at line 232 of file Json.php.
|
staticprotected |
_processXml - Contains the logic for xml2json
The logic in this function is a recursive one.
The main caller of this function (i.e. fromXml) needs to provide only the first two parameters i.e. the SimpleXMLElement object and the flag for ignoring or not ignoring XML attributes. The third parameter will be used internally within this function during the recursive calls.
This function converts the SimpleXMLElement object into a PHP array by calling a recursive (protected static) function in this class. Once all the XML elements are stored in the PHP array, it is returned to the caller.
Throws a Zend_Json_Exception if the XML tree is deeper than the allowed limit.
SimpleXMLElement | $simpleXmlElementObject | |
boolean | $ignoreXmlAttributes | |
integer | $recursionDepth |
Definition at line 263 of file Json.php.
|
staticprotected |
Check & Replace Zend_Json_Expr for tmp ids in the valueToEncode
Check if the value is a Zend_Json_Expr, and if replace its value with a magic key and save the javascript expression in an array.
NOTE this method is recursive.
NOTE: This method is used internally by the encode method.
array | object | Zend_Json_Expr | $value | a string - object property to be encoded |
array | $javascriptExpressions | |
null | $currentKey |
Definition at line 197 of file Json.php.
|
static |
Decodes the given $encodedValue string which is encoded in the JSON format
Uses ext/json's json_decode if available.
string | $encodedValue | Encoded in JSON format |
int | $objectDecodeType | Optional; flag indicating how to decode objects. See Zend_Json_Decoder::decode() for details. |
Definition at line 74 of file Json.php.
|
static |
Encode the mixed $valueToEncode into the JSON format
Encodes using ext/json's json_encode() if available.
NOTE: Object should not contain cycles; the JSON format does not allow object reference.
NOTE: Only public variables will be encoded
NOTE: Encoding native javascript expressions are possible using Zend_Json_Expr. You can enable this by setting $options['enableJsonExprFinder'] = true
mixed | $valueToEncode | |
boolean | $cycleCheck | Optional; whether or not to check for object recursion; off by default |
array | $options | Additional options used during encoding |
Definition at line 130 of file Json.php.
|
static |
fromXml - Converts XML to JSON
Converts a XML formatted string into a JSON formatted string. The value returned will be a string in JSON format.
The caller of this function needs to provide only the first parameter, which is an XML formatted String. The second parameter is optional, which lets the user to select if the XML attributes in the input XML string should be included or ignored in xml2json conversion.
This function converts the XML formatted string into a PHP array by calling a recursive (protected static) function in this class. Then, it converts that PHP array into JSON by calling the "encode" static funcion.
Throws a Zend_Json_Exception if the input not a XML formatted string. NOTE: Encoding native javascript expressions via Zend_Json_Expr is not possible.
@access public
string | $xmlStringContents | XML String to be converted |
boolean | $ignoreXmlAttributes | Include or exclude XML attributes in the xml2json conversion process. |
Zend_Json_Exception |
Definition at line 345 of file Json.php.
|
static |
Pretty-print JSON string
Use 'format' option to select output format - currently html and txt supported, txt is default Use 'indent' option to override the indentation string set in the format - by default for the 'txt' format it's a tab
string | $json | Original JSON string |
array | $options | Encoding options |
Definition at line 379 of file Json.php.
const TYPE_ARRAY = 1 |