System.Web.Services.AJAX
[ class tree: System.Web.Services.AJAX ] [ index: System.Web.Services.AJAX ] [ all elements ]

Class: TJSON

Source Location: /Web/Services/AJAX/TJSON.php

Class Overview


Converts to and from JSON format.

Class Details

[line 70]
Converts to and from JSON format.



license:  PHP License 3.0
copyright:  2005 Michal Migurski
author:  Michal Migurski <mike-json@teczno.com>
author:  Matt Knapp <mdknapp[at]gmail[dot]com>
author:  Brett Stimmerman <brettstimmerman[at]gmail[dot]com>


[ Top ]

Constants

Methods



Class Methods


constructor __construct [line 119]

TJSON __construct( [int $use = self::JSON_STRICT_TYPE])

constructs a new JSON instance



access:  public


Parameters:

int   $use  

object behavior: when encoding or decoding, be loose or strict about object/array usage

possible values: self::JSON_STRICT_TYPE - strict typing, default "{...}" syntax creates objects in decode. self::JSON_LOOSE_TYPE - loose typing "{...}" syntax creates associative arrays in decode.


[ Top ]

method dec [line 656]

mixed dec( mixed $var, string $str)

decodes a JSON string into appropriate variable; alias for decode()



return:  number, boolean, string, array, or object corresponding to given JSON input string. See argument 1 to JSON() above for object-output behavior. Note that decode() always returns strings in ASCII or UTF-8 format!
access:  public
see:  JSON::decode()


Parameters:

string   $str   JSON-formatted string

[ Top ]

method decode [line 370]

mixed decode( string $str)

decodes a JSON string into appropriate variable



return:  number, boolean, string, array, or object corresponding to given JSON input string. See argument 1 to JSON() above for object-output behavior. Note that decode() always returns strings in ASCII or UTF-8 format!
access:  public


Parameters:

string   $str   JSON-formatted string

[ Top ]

method enc [line 312]

string enc( mixed $var)

encodes an arbitrary variable into JSON format, alias for encode()



return:  JSON string representation of input var
access:  public
see:  JSON::encode()


Parameters:

mixed   $var   any number, boolean, string, array, or object to be encoded. see argument 1 to JSON() above for array-parsing behavior. if var is a strng, note that encode() always expects it to be in ASCII or UTF-8 format!

[ Top ]

method encode [line 135]

string encode( mixed $var)

encodes an arbitrary variable into JSON format



return:  JSON string representation of input var
access:  public


Parameters:

mixed   $var   any number, boolean, string, array, or object to be encoded. see argument 1 to JSON() above for array-parsing behavior. if var is a strng, note that encode() always expects it to be in ASCII or UTF-8 format!

[ Top ]

method name_value [line 326]

string name_value( string $name, mixed $value)

function name_value array-walking function for use in generating JSON-formatted name-value pairs



return:  JSON-formatted name-value pair, like '"name":value'
access:  protected


Parameters:

string   $name   name of key to use
mixed   $value   reference to an array element to be encoded

[ Top ]

method reduce_string [line 339]

string reduce_string( $str $str)

reduce a string by removing leading and trailing comments and whitespace



return:  string value stripped of comments and whitespace
access:  protected


Parameters:

$str   $str   string string value to strip of comments and whitespace

[ Top ]

method unicode_to_utf8 [line 707]

void unicode_to_utf8( mixed &$str)

This function converts a Unicode array back to its UTF-8 representation



access:  protected
see:  TJSON::utf8_to_unicode()
link:  http://www.randomchaos.com/document.php?source=php_and_unicode
author:  Scott Michael Reynen <scott@randomchaos.com>


[ Top ]

method utf8_to_unicode [line 670]

void utf8_to_unicode( mixed &$str)

This function returns any UTF-8 encoded text as a list of Unicode values:



access:  protected
see:  TJSON::unicode_to_utf8()
link:  http://www.randomchaos.com/document.php?source=php_and_unicode
author:  Scott Michael Reynen <scott@randomchaos.com>


[ Top ]

method utf8_to_utf16be [line 736]

void utf8_to_utf16be( mixed &$str, [mixed $bom = false])

UTF-8 to UTF-16BE conversion.

Maybe really UCS-2 without mb_string due to utf8_to_unicode limits




access:  protected


[ Top ]

method utf16be_to_utf8 [line 753]

void utf16be_to_utf8( mixed &$str)

UTF-8 to UTF-16BE conversion.

Maybe really UCS-2 without mb_string due to utf8_to_unicode limits




access:  protected


[ Top ]


Class Constants

JSON_IN_ARR =  4

[line 85]

Marker constant for JSON::decode(), used to flag stack state


[ Top ]

JSON_IN_CMT =  16

[line 95]

Marker constant for JSON::decode(), used to flag stack state


[ Top ]

JSON_IN_OBJ =  8

[line 90]

Marker constant for JSON::decode(), used to flag stack state


[ Top ]

JSON_IN_STR =  2

[line 80]

Marker constant for JSON::decode(), used to flag stack state


[ Top ]

JSON_LOOSE_TYPE =  10

[line 100]

Behavior switch for JSON::decode()


[ Top ]

JSON_SLICE =  1

[line 75]

Marker constant for JSON::decode(), used to flag stack state


[ Top ]

JSON_STRICT_TYPE =  11

[line 105]

Behavior switch for JSON::decode()


[ Top ]



© 2004-2005 PRADO Software Group. All Rights Reserved.