[ Index ] |
PHP Cross Reference of MediaWiki-1.24.0 |
[Source view] [Print] [Project Stats]
Wrapper for json_encode and json_decode. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
File Size: | 350 lines (12 kb) |
Included or required: | 0 times |
Referenced: | 1 time |
Includes or requires: | 0 files |
Class: FormatJson - X-Ref
JSON formatter wrapper classencode( $value, $pretty = false, $escaping = 0 ) X-Ref |
Returns the JSON representation of a value. param: mixed $value The value to encode. Can be any type except a resource. param: string|bool $pretty If a string, add non-significant whitespace to improve param: int $escaping Bitfield consisting of _OK class constants return: string|bool: String if successful; false upon failure |
decode( $value, $assoc = false ) X-Ref |
Decodes a JSON string. It is recommended to use FormatJson::parse(), which returns more comprehensive result in case of an error, and has more parsing options. param: string $value The JSON string being decoded param: bool $assoc When true, returned objects will be converted into associative arrays. return: mixed The value encoded in JSON in appropriate PHP type. |
parse( $value, $options = 0 ) X-Ref |
Decodes a JSON string. Unlike FormatJson::decode(), if $value represents null value, it will be properly decoded as valid. param: string $value The JSON string being decoded param: int $options A bit field that allows FORCE_ASSOC, TRY_FIXING return: Status If valid JSON, the value is available in $result->getValue() |
encode54( $value, $pretty, $escaping ) X-Ref |
JSON encoder wrapper for PHP >= 5.4, which supports useful encoding options. param: mixed $value param: string|bool $pretty param: int $escaping return: string|bool |
encode53( $value, $pretty, $escaping ) X-Ref |
JSON encoder wrapper for PHP 5.3, which lacks native support for some encoding options. Therefore, the missing options are implemented here purely in PHP code. param: mixed $value param: string|bool $pretty param: int $escaping return: string|bool |
prettyPrint( $json, $indentString ) X-Ref |
Adds non-significant whitespace to an existing JSON representation of an object. Only needed for PHP < 5.4, which lacks the JSON_PRETTY_PRINT option. param: string $json param: string $indentString return: string |
Generated: Fri Nov 28 14:03:12 2014 | Cross-referenced by PHPXref 0.7.1 |