C# Class Playtomic.JSON

This class encodes and decodes JSON strings. Spec. details, see http://www.json.org/ JSON uses Arrays and Objects. These correspond here to the datatypes ArrayList and Hashtable. All numbers are parsed to doubles.
Afficher le fichier Open project: playtomic/gameapi-csharp

Protected Properties

Свойство Type Description
lastDecode string
lastErrorIndex int

Méthodes publiques

Méthode Description
GetLastErrorIndex ( ) : int

On decoding, this function returns the position at which the parse failed (-1 = no error).

GetLastErrorSnippet ( ) : string

If a decoding error occurred, this function returns a piece of the JSON string at which the error took place. To ease debugging.

JsonDecode ( string json ) : object

Parses the string json into a value

JsonEncode ( object json ) : string

Converts a Hashtable / ArrayList object into a JSON string

LastDecodeSuccessful ( ) : bool

On decoding, this function returns the position at which the parse failed (-1 = no error).

Méthodes protégées

Méthode Description
EatWhitespace ( char json, int &index ) : void
GetLastIndexOfNumber ( char json, int index ) : int
IsNumeric ( object o ) : bool

Determines if a given object is numeric in any way (can be integer, double, etc). C# has no pretty way to do this.

LookAhead ( char json, int index ) : int
NextToken ( char json, int &index ) : int
ParseArray ( char json, int &index ) : ArrayList
ParseNumber ( char json, int &index ) : double
ParseObject ( char json, int &index ) : Hashtable
ParseString ( char json, int &index ) : string
ParseValue ( char json, int &index, bool &success ) : object
SerializeArray ( ArrayList anArray, StringBuilder builder ) : bool
SerializeNumber ( double number, StringBuilder builder ) : void
SerializeObject ( Hashtable anObject, StringBuilder builder ) : bool
SerializeObjectOrArray ( object objectOrArray, StringBuilder builder ) : bool
SerializeString ( string aString, StringBuilder builder ) : void
SerializeValue ( object value, StringBuilder builder ) : bool

Method Details

EatWhitespace() protected méthode

protected EatWhitespace ( char json, int &index ) : void
json char
index int
Résultat void

GetLastErrorIndex() public static méthode

On decoding, this function returns the position at which the parse failed (-1 = no error).
public static GetLastErrorIndex ( ) : int
Résultat int

GetLastErrorSnippet() public static méthode

If a decoding error occurred, this function returns a piece of the JSON string at which the error took place. To ease debugging.
public static GetLastErrorSnippet ( ) : string
Résultat string

GetLastIndexOfNumber() protected méthode

protected GetLastIndexOfNumber ( char json, int index ) : int
json char
index int
Résultat int

IsNumeric() protected méthode

Determines if a given object is numeric in any way (can be integer, double, etc). C# has no pretty way to do this.
protected IsNumeric ( object o ) : bool
o object
Résultat bool

JsonDecode() public static méthode

Parses the string json into a value
public static JsonDecode ( string json ) : object
json string A JSON string.
Résultat object

JsonEncode() public static méthode

Converts a Hashtable / ArrayList object into a JSON string
public static JsonEncode ( object json ) : string
json object A Hashtable / ArrayList
Résultat string

LastDecodeSuccessful() public static méthode

On decoding, this function returns the position at which the parse failed (-1 = no error).
public static LastDecodeSuccessful ( ) : bool
Résultat bool

LookAhead() protected méthode

protected LookAhead ( char json, int index ) : int
json char
index int
Résultat int

NextToken() protected méthode

protected NextToken ( char json, int &index ) : int
json char
index int
Résultat int

ParseArray() protected méthode

protected ParseArray ( char json, int &index ) : ArrayList
json char
index int
Résultat System.Collections.ArrayList

ParseNumber() protected méthode

protected ParseNumber ( char json, int &index ) : double
json char
index int
Résultat double

ParseObject() protected méthode

protected ParseObject ( char json, int &index ) : Hashtable
json char
index int
Résultat System.Collections.Hashtable

ParseString() protected méthode

protected ParseString ( char json, int &index ) : string
json char
index int
Résultat string

ParseValue() protected méthode

protected ParseValue ( char json, int &index, bool &success ) : object
json char
index int
success bool
Résultat object

SerializeArray() protected méthode

protected SerializeArray ( ArrayList anArray, StringBuilder builder ) : bool
anArray System.Collections.ArrayList
builder StringBuilder
Résultat bool

SerializeNumber() protected méthode

protected SerializeNumber ( double number, StringBuilder builder ) : void
number double
builder StringBuilder
Résultat void

SerializeObject() protected méthode

protected SerializeObject ( Hashtable anObject, StringBuilder builder ) : bool
anObject System.Collections.Hashtable
builder StringBuilder
Résultat bool

SerializeObjectOrArray() protected méthode

protected SerializeObjectOrArray ( object objectOrArray, StringBuilder builder ) : bool
objectOrArray object
builder StringBuilder
Résultat bool

SerializeString() protected méthode

protected SerializeString ( string aString, StringBuilder builder ) : void
aString string
builder StringBuilder
Résultat void

SerializeValue() protected méthode

protected SerializeValue ( object value, StringBuilder builder ) : bool
value object
builder StringBuilder
Résultat bool

Property Details

lastDecode protected_oe property

protected string lastDecode
Résultat string

lastErrorIndex protected_oe property

On decoding, this value holds the position at which the parse failed (-1 = no error).
protected int lastErrorIndex
Résultat int