C# Класс ThermostatMonitorLib.JSON

JSON Helper library is from: http://techblog.procurios.nl/k/n618/news/view/14605/14863/How-do-I-write-my-own-parser-for-JSON.html?pageNr=3 and is subject to the MIT license (http://www.opensource.org/licenses/mit-license.php). .NET 4.0 has native JSON support, but I chose to use this helper instead to make this library accessible to more developers. 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.
Показать файл Открыть проект

Открытые методы

Метод Описание
JsonDecode ( string json ) : object

Parses the string json into a value

JsonDecode ( string json, bool &success ) : object

Parses the string json into a value; and fills 'success' with the successfullness of the parse.

JsonEncode ( object json ) : string

Converts a Hashtable / ArrayList object into a JSON string

Защищенные методы

Метод Описание
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, null, etc). Thanks to mtighe for pointing out Double.TryParse to me.

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

Описание методов

EatWhitespace() защищенный статический Метод

protected static EatWhitespace ( char json, int &index ) : void
json char
index int
Результат void

GetLastIndexOfNumber() защищенный статический Метод

protected static GetLastIndexOfNumber ( char json, int index ) : int
json char
index int
Результат int

IsNumeric() защищенный статический Метод

Determines if a given object is numeric in any way (can be integer, double, null, etc). Thanks to mtighe for pointing out Double.TryParse to me.
protected static IsNumeric ( object o ) : bool
o object
Результат bool

JsonDecode() публичный статический Метод

Parses the string json into a value
public static JsonDecode ( string json ) : object
json string A JSON string.
Результат object

JsonDecode() публичный статический Метод

Parses the string json into a value; and fills 'success' with the successfullness of the parse.
public static JsonDecode ( string json, bool &success ) : object
json string A JSON string.
success bool Successful parse?
Результат object

JsonEncode() публичный статический Метод

Converts a Hashtable / ArrayList object into a JSON string
public static JsonEncode ( object json ) : string
json object A Hashtable / ArrayList
Результат string

LookAhead() защищенный статический Метод

protected static LookAhead ( char json, int index ) : int
json char
index int
Результат int

NextToken() защищенный статический Метод

protected static NextToken ( char json, int &index ) : int
json char
index int
Результат int

ParseArray() защищенный статический Метод

protected static ParseArray ( char json, int &index, bool &success ) : ArrayList
json char
index int
success bool
Результат ArrayList

ParseNumber() защищенный статический Метод

protected static ParseNumber ( char json, int &index, bool &success ) : double
json char
index int
success bool
Результат double

ParseObject() защищенный статический Метод

protected static ParseObject ( char json, int &index, bool &success ) : Hashtable
json char
index int
success bool
Результат Hashtable

ParseString() защищенный статический Метод

protected static ParseString ( char json, int &index, bool &success ) : string
json char
index int
success bool
Результат string

ParseValue() защищенный статический Метод

protected static ParseValue ( char json, int &index, bool &success ) : object
json char
index int
success bool
Результат object

SerializeArray() защищенный статический Метод

protected static SerializeArray ( ArrayList anArray, StringBuilder builder ) : bool
anArray ArrayList
builder StringBuilder
Результат bool

SerializeNumber() защищенный статический Метод

protected static SerializeNumber ( double number, StringBuilder builder ) : bool
number double
builder StringBuilder
Результат bool

SerializeObject() защищенный статический Метод

protected static SerializeObject ( Hashtable anObject, StringBuilder builder ) : bool
anObject Hashtable
builder StringBuilder
Результат bool

SerializeString() защищенный статический Метод

protected static SerializeString ( string aString, StringBuilder builder ) : bool
aString string
builder StringBuilder
Результат bool

SerializeValue() защищенный статический Метод

protected static SerializeValue ( object value, StringBuilder builder ) : bool
value object
builder StringBuilder
Результат bool