MediaWiki  master
FormatJson Class Reference

JSON formatter wrapper class. More...

List of all members.

Static Public Member Functions

static decode ($value, $assoc=false)
 Decodes a JSON string.
static encode ($value, $isHtml=false)
 Returns the JSON representation of a value.

Detailed Description

JSON formatter wrapper class.

Definition at line 28 of file FormatJson.php.


Member Function Documentation

static FormatJson::decode ( value,
assoc = false 
) [static]

Decodes a JSON string.

Parameters:
$valueString: the json string being decoded.
$assocBoolean: when true, returned objects will be converted into associative arrays.
Returns:
Mixed: the value encoded in json in appropriate PHP type. Values true, false and null (case-insensitive) are returned as true, false and "&null;" respectively. "&null;" is returned if the json cannot be decoded or if the encoded data is deeper than the recursion limit.

Definition at line 63 of file FormatJson.php.

References $value.

Referenced by ForeignAPIRepo\fetchImageQuery(), ResourceLoaderModule\getFileDependencies(), MessageBlobStore\getFromDB(), MediaWikiSite\normalizePageName(), ResourceLoader\preloadModuleInfo(), MessageBlobStore\reencodeBlob(), JsonTest\testDecodeVarTypes(), and MessageBlobStore\updateModule().

static FormatJson::encode ( value,
isHtml = false 
) [static]

Returns the JSON representation of a value.

Parameters:
$valueMixed: the value being encoded. Can be any type except a resource.
$isHtmlBoolean
Todo:
FIXME: "$isHtml" parameter's purpose is not documented. It appears to map to a parameter labeled "pretty-print output with indents and newlines" in Services_JSON::encode(), which has no string relation to HTML output.
Returns:
string

Definition at line 43 of file FormatJson.php.

References $value.

Referenced by ApiFormatJson\execute(), MessageBlobStore\generateMessageBlob(), ResourceLoaderFileModule\getStyles(), MessageBlobStore\reencodeBlob(), JsonTest\testPhpBug46944Test(), and GenerateJqueryMsgData\writeJavascriptFile().


The documentation for this class was generated from the following file: