C# Class GA_MiniJSON, TheUnseen

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 floats.
Exibir arquivo Open project: henryj41043/TheUnseen Class Usage Examples

Protected Properties

Property Type Description
instance GA_MiniJSON,
lastDecode string
lastErrorIndex int

Public Methods

Method 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).

Protected Methods

Method Description
EatWhitespace ( char json, int &index ) : void
GetLastIndexOfNumber ( char json, int index ) : int
LookAhead ( char json, int index ) : int
NextToken ( char json, int &index ) : int
ParseArray ( char json, int &index ) : ArrayList
ParseNumber ( char json, int &index ) : float
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 ( float 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 method

protected EatWhitespace ( char json, int &index ) : void
json char
index int
return void

GetLastErrorIndex() public static method

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

GetLastErrorSnippet() public static method

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
return string

GetLastIndexOfNumber() protected method

protected GetLastIndexOfNumber ( char json, int index ) : int
json char
index int
return int

JsonDecode() public static method

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

JsonEncode() public static method

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

LastDecodeSuccessful() public static method

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

LookAhead() protected method

protected LookAhead ( char json, int index ) : int
json char
index int
return int

NextToken() protected method

protected NextToken ( char json, int &index ) : int
json char
index int
return int

ParseArray() protected method

protected ParseArray ( char json, int &index ) : ArrayList
json char
index int
return ArrayList

ParseNumber() protected method

protected ParseNumber ( char json, int &index ) : float
json char
index int
return float

ParseObject() protected method

protected ParseObject ( char json, int &index ) : Hashtable
json char
index int
return Hashtable

ParseString() protected method

protected ParseString ( char json, int &index ) : string
json char
index int
return string

ParseValue() protected method

protected ParseValue ( char json, int &index, bool &success ) : object
json char
index int
success bool
return object

SerializeArray() protected method

protected SerializeArray ( ArrayList anArray, StringBuilder builder ) : bool
anArray ArrayList
builder StringBuilder
return bool

SerializeNumber() protected method

protected SerializeNumber ( float number, StringBuilder builder ) : void
number float
builder StringBuilder
return void

SerializeObject() protected method

protected SerializeObject ( Hashtable anObject, StringBuilder builder ) : bool
anObject Hashtable
builder StringBuilder
return bool

SerializeObjectOrArray() protected method

protected SerializeObjectOrArray ( object objectOrArray, StringBuilder builder ) : bool
objectOrArray object
builder StringBuilder
return bool

SerializeString() protected method

protected SerializeString ( string aString, StringBuilder builder ) : void
aString string
builder StringBuilder
return void

SerializeValue() protected method

protected SerializeValue ( object value, StringBuilder builder ) : bool
value object
builder StringBuilder
return bool

Property Details

instance protected_oe static_oe property

protected static GA_MiniJSON, instance
return GA_MiniJSON,

lastDecode protected_oe property

protected string lastDecode
return string

lastErrorIndex protected_oe property

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