C# Class Poonya.Utils.Json

Provides functions for encoding and decoding files in the JSON format.
Mostra file Open project: sunag/sea3d

Public Methods

Method Description
Decode ( byte sjson ) : object

Decodes a JSON bytestream into a hash table with numbers, bools, strings, ArrayLists and Hashtables.

Encode ( object t ) : string

Encodes the hashtable t in the JSON format. The hash table can contain, numbers, bools, strings, ArrayLists and Hashtables.

Load ( string path ) : Hashtable

Convenience function for loading a file.

Save ( Hashtable h, string path ) : void

Convenience function for saving a file.

Write ( object o, StringBuilder builder, int indentation ) : void

Writes a generic object.

WriteArray ( System.Collections.ArrayList a, StringBuilder builder, int indentation ) : void

Writes an array of items.

WriteNewLine ( StringBuilder builder, int indentation ) : void

Writes a newline and the desired ammount of indentation.

WriteObject ( System.Collections.Hashtable t, StringBuilder builder, int indentation ) : void

Writes a JSON object.

WriteObjectField ( System.Collections.Hashtable t, string key, bool write_comma, StringBuilder builder, int indentation ) : void

Writes a particular field in a JSON object.

WriteObjectFields ( System.Collections.Hashtable t, StringBuilder builder, int indentation ) : void

Writes all the fields of a JSON object.

WriteString ( String s, StringBuilder builder ) : void

Writes a string.

Private Methods

Method Description
AtEnd ( byte json, int &index ) : bool
Consume ( byte json, int &index, String consume ) : void
Next ( byte json, int &index ) : byte
Parse ( byte json, int &index ) : object
ParseArray ( byte json, int &index ) : ArrayList
ParseBinary ( byte json, int &index ) : byte[]
ParseNumber ( byte json, int &index ) : Double
ParseObject ( byte json, int &index ) : Hashtable
ParseString ( byte json, int &index ) : String
SkipWhitespace ( byte json, int &index ) : void

Method Details

Decode() public static method

Decodes a JSON bytestream into a hash table with numbers, bools, strings, ArrayLists and Hashtables.
public static Decode ( byte sjson ) : object
sjson byte
return object

Encode() public static method

Encodes the hashtable t in the JSON format. The hash table can contain, numbers, bools, strings, ArrayLists and Hashtables.
public static Encode ( object t ) : string
t object
return string

Load() public static method

Convenience function for loading a file.
public static Load ( string path ) : Hashtable
path string
return Hashtable

Save() public static method

Convenience function for saving a file.
public static Save ( Hashtable h, string path ) : void
h Hashtable
path string
return void

Write() public static method

Writes a generic object.
public static Write ( object o, StringBuilder builder, int indentation ) : void
o object
builder StringBuilder
indentation int
return void

WriteArray() public static method

Writes an array of items.
public static WriteArray ( System.Collections.ArrayList a, StringBuilder builder, int indentation ) : void
a System.Collections.ArrayList
builder StringBuilder
indentation int
return void

WriteNewLine() public static method

Writes a newline and the desired ammount of indentation.
public static WriteNewLine ( StringBuilder builder, int indentation ) : void
builder StringBuilder
indentation int
return void

WriteObject() public static method

Writes a JSON object.
public static WriteObject ( System.Collections.Hashtable t, StringBuilder builder, int indentation ) : void
t System.Collections.Hashtable
builder StringBuilder
indentation int
return void

WriteObjectField() public static method

Writes a particular field in a JSON object.
public static WriteObjectField ( System.Collections.Hashtable t, string key, bool write_comma, StringBuilder builder, int indentation ) : void
t System.Collections.Hashtable
key string
write_comma bool
builder StringBuilder
indentation int
return void

WriteObjectFields() public static method

Writes all the fields of a JSON object.
public static WriteObjectFields ( System.Collections.Hashtable t, StringBuilder builder, int indentation ) : void
t System.Collections.Hashtable
builder StringBuilder
indentation int
return void

WriteString() public static method

Writes a string.
public static WriteString ( String s, StringBuilder builder ) : void
s String
builder StringBuilder
return void