Overview

Packages

  • Components
  • Internals
    • AR
  • RestApi
    • Objects
    • Services

Classes

  • CBHttpRequest
  • CBJson
  • CBJsonController
  • CBJsonInlineAction
  • CBJsonModel
  • Overview
  • Package
  • Class
  • Tree
  • Todo

Class CBJson

Json helper functions.

Adds the following functionality:
  • JSON string validation: CBJson::isValid()
  • JSON formatting/indentation: CBJson::indent()
  • JSON soft decoding: CBJson::softDecode*() (does not fail if json is invalid)
Package: Components
Author: Konstantinos Filios <konfilios@gmail.com>
Since: 1.0
Located at components/CBJson.php
Methods summary
public static boolean
# isValid( string $json )

Check if passed string is valid json.

Check if passed string is valid json.

Parameters

$json
string
$json Json string.

Returns

boolean
True if passed $json is valid
public static string
# indent( string $json, string $indentStr = ' ', string $newLine = "\n" )

Indent passed $json string to increase human-readability.

Indent passed $json string to increase human-readability.

Parameters

$json
string
$json Unformatted json.
$indentStr
string
$indentStr Indentation string (tabulator).
$newLine
string
$newLine Line terminator.

Returns

string

See

http://recursive-design.com/blog/2008/03/11/format-json-with-php/
public static string
# getLastErrorString( )

Returns string/text describing the last error occured while json encoding/decoding.

Returns string/text describing the last error occured while json encoding/decoding.

This is supported only for php 5.3 or later.

Returns

string

See

http://www.php.net/manual/en/function.json-last-error.php
public static mixed
# softDecode( string $jsonInput )

Try to json-decode input.

Try to json-decode input.

Parameters

$jsonInput
string
$jsonInput

Returns

mixed
public static array
# softDecodeArray( array $jsonInputs )

Try to json-decode array elements.

Try to json-decode array elements.

If elements are not json-decoded their original values are retained.

Parameters

$jsonInputs
array
$jsonInputs

Returns

array
public static mixed
# decodeAssoc( string $jsonInput )

Decode json input.

Decode json input.

Parameters

$jsonInput
string
$jsonInput

Returns

mixed

Throws

CException
Bogo Yii Json Service API documentation generated by ApiGen 2.8.0