public static function maybeDecode($value, $asArray = false)
    {
        if (!is_string($value)) {
            return $value;
        }

        $decoded = json_decode($value, $asArray);

        if (json_last_error() == JSON_ERROR_NONE && (is_object($decoded) || is_array($decoded))) {
            return $decoded;
        } else {
            // Reset the JSON error code:
            json_decode("[]");

            return $value;
        }
    }
public static function maybeDecode($value, $asArray = false)
    {
        if (!is_string($value)) {
            return $value;
        }

        $decoded = json_decode($value, $asArray);

        if (json_last_error() == JSON_ERROR_NONE && (is_object($decoded) || is_array($decoded))) {
            return $decoded;
        } else {
            // Reset the JSON error code:
            json_decode("[]");

            return $value;
        }
    }
public static function maybeDecode ( $ value , $ asArray = false ) { if ( ! is_string ( $ value ) ) { return $ value ; } $ decoded = json_decode ( $ value , $ asArray ) ; if ( json_last_error ( ) == JSON_ERROR_NONE && ( is_object ( $ decoded ) || is_array ( $ decoded ) ) ) { return $ decoded ; } else { // Reset the JSON error code: json_decode ( "[]" ) ; return $ value ; } }
Checks if a value is json encoded

@param $value
@param bool $asArray
@return mixed
Checks if a value is json encoded