C# Class Flood.Serialization.JSONSerializer

JSON protocol implementation for thrift. This is a full-featured protocol supporting Write and Read. Please see the C++ class header for a detailed description of the protocol's wire format. Adapted from the Java version.
Inheritance: Serializer
显示文件 Open project: FloodProject/flood Class Usage Examples

Protected Properties

Property Type Description
context JSONBaseContext
contextStack Stack
reader LookaheadReader
utf8Encoding System.Text.Encoding

Public Methods

Method Description
JSONSerializer ( System stream ) : System

JSONProtocol Constructor

ReadBinary ( ) : byte[]
ReadBool ( ) : bool
ReadByte ( ) : byte
ReadDataObjectBegin ( ) : DataObject
ReadDataObjectEnd ( ) : void
ReadDouble ( ) : double
ReadFieldBegin ( ) : Field
ReadFieldEnd ( ) : void
ReadI16 ( ) : short
ReadI32 ( ) : int
ReadI64 ( ) : long
ReadListBegin ( ) : TList
ReadListEnd ( ) : void
ReadMapBegin ( ) : TMap
ReadMapEnd ( ) : void
ReadString ( ) : String
WriteBinary ( byte bin ) : void
WriteBool ( bool b ) : void
WriteByte ( byte b ) : void
WriteDataObjectBegin ( DataObject str ) : void
WriteDataObjectEnd ( ) : void
WriteDouble ( double dub ) : void
WriteFieldBegin ( Field field ) : void
WriteFieldEnd ( ) : void
WriteFieldStop ( ) : void
WriteI16 ( short i16 ) : void
WriteI32 ( int i32 ) : void
WriteI64 ( long i64 ) : void
WriteListBegin ( TList list ) : void
WriteListEnd ( ) : void
WriteMapBegin ( TMap map ) : void
WriteMapEnd ( ) : void
WriteString ( String str ) : void

Protected Methods

Method Description
PopContext ( ) : void

Pop the last JSON context off the stack

PushContext ( JSONBaseContext c ) : void

Push a new JSON context onto the stack.

ReadJSONSyntaxChar ( byte b ) : void

Read a byte that must match b[0]; otherwise an exception is thrown. Marked protected to avoid synthetic accessor in JSONListContext.Read and JSONPairContext.Read

Private Methods

Method Description
GetTypeIDForTypeName ( byte name ) : DataType
GetTypeNameForTypeID ( DataType typeID ) : byte[]
HexChar ( byte val ) : byte

Convert a byte containing a hex value to its corresponding hex character

HexVal ( byte ch ) : byte

Convert a byte containing a hex char ('0'-'9' or 'a'-'f') into its corresponding hex value

IsJSONNumeric ( byte b ) : bool

Return true if the given byte could be a valid part of a JSON number.

ReadJSONArrayEnd ( ) : void
ReadJSONArrayStart ( ) : void
ReadJSONBase64 ( ) : byte[]

Read in a JSON string containing base-64 encoded data and decode it.

ReadJSONDouble ( ) : double

Read in a JSON double value. Throw if the value is not wrapped in quotes when expected or if wrapped in quotes when not expected.

ReadJSONInteger ( ) : long

Read in a JSON number. If the context dictates, Read in enclosing quotes.

ReadJSONNumericChars ( ) : String

Read in a sequence of characters that are all valid in JSON numbers. Does not do a complete regex check to validate that this is actually a number.

ReadJSONObjectEnd ( ) : void
ReadJSONObjectStart ( ) : void
ReadJSONString ( bool skipContext ) : byte[]

Read in a JSON string, unescaping as appropriate.. Skip Reading from the context if skipContext is true.

WriteJSONArrayEnd ( ) : void
WriteJSONArrayStart ( ) : void
WriteJSONBase64 ( byte b ) : void

Write out contents of byte array b as a JSON string with base-64 encoded data

WriteJSONDouble ( double num ) : void

Write out a double as a JSON value. If it is NaN or infinity or if the context dictates escaping, Write out as JSON string.

WriteJSONInteger ( long num ) : void

Write out number as a JSON value. If the context dictates so, it will be wrapped in quotes to output as a JSON string.

WriteJSONObjectEnd ( ) : void
WriteJSONObjectStart ( ) : void
WriteJSONString ( byte b ) : void

Write the bytes in array buf as a JSON characters, escaping as needed

Method Details

JSONSerializer() public method

JSONProtocol Constructor
public JSONSerializer ( System stream ) : System
stream System
return System

PopContext() protected method

Pop the last JSON context off the stack
protected PopContext ( ) : void
return void

PushContext() protected method

Push a new JSON context onto the stack.
protected PushContext ( JSONBaseContext c ) : void
c JSONBaseContext
return void

ReadBinary() public method

public ReadBinary ( ) : byte[]
return byte[]

ReadBool() public method

public ReadBool ( ) : bool
return bool

ReadByte() public method

public ReadByte ( ) : byte
return byte

ReadDataObjectBegin() public method

public ReadDataObjectBegin ( ) : DataObject
return DataObject

ReadDataObjectEnd() public method

public ReadDataObjectEnd ( ) : void
return void

ReadDouble() public method

public ReadDouble ( ) : double
return double

ReadFieldBegin() public method

public ReadFieldBegin ( ) : Field
return Field

ReadFieldEnd() public method

public ReadFieldEnd ( ) : void
return void

ReadI16() public method

public ReadI16 ( ) : short
return short

ReadI32() public method

public ReadI32 ( ) : int
return int

ReadI64() public method

public ReadI64 ( ) : long
return long

ReadJSONSyntaxChar() protected method

Read a byte that must match b[0]; otherwise an exception is thrown. Marked protected to avoid synthetic accessor in JSONListContext.Read and JSONPairContext.Read
protected ReadJSONSyntaxChar ( byte b ) : void
b byte
return void

ReadListBegin() public method

public ReadListBegin ( ) : TList
return TList

ReadListEnd() public method

public ReadListEnd ( ) : void
return void

ReadMapBegin() public method

public ReadMapBegin ( ) : TMap
return TMap

ReadMapEnd() public method

public ReadMapEnd ( ) : void
return void

ReadString() public method

public ReadString ( ) : String
return String

WriteBinary() public method

public WriteBinary ( byte bin ) : void
bin byte
return void

WriteBool() public method

public WriteBool ( bool b ) : void
b bool
return void

WriteByte() public method

public WriteByte ( byte b ) : void
b byte
return void

WriteDataObjectBegin() public method

public WriteDataObjectBegin ( DataObject str ) : void
str DataObject
return void

WriteDataObjectEnd() public method

public WriteDataObjectEnd ( ) : void
return void

WriteDouble() public method

public WriteDouble ( double dub ) : void
dub double
return void

WriteFieldBegin() public method

public WriteFieldBegin ( Field field ) : void
field Field
return void

WriteFieldEnd() public method

public WriteFieldEnd ( ) : void
return void

WriteFieldStop() public method

public WriteFieldStop ( ) : void
return void

WriteI16() public method

public WriteI16 ( short i16 ) : void
i16 short
return void

WriteI32() public method

public WriteI32 ( int i32 ) : void
i32 int
return void

WriteI64() public method

public WriteI64 ( long i64 ) : void
i64 long
return void

WriteListBegin() public method

public WriteListBegin ( TList list ) : void
list TList
return void

WriteListEnd() public method

public WriteListEnd ( ) : void
return void

WriteMapBegin() public method

public WriteMapBegin ( TMap map ) : void
map TMap
return void

WriteMapEnd() public method

public WriteMapEnd ( ) : void
return void

WriteString() public method

public WriteString ( String str ) : void
str String
return void

Property Details

context protected_oe property

protected JSONBaseContext context
return JSONBaseContext

contextStack protected_oe property

protected Stack contextStack
return Stack

reader protected_oe property

protected LookaheadReader reader
return LookaheadReader

utf8Encoding protected_oe property

protected Encoding,System.Text utf8Encoding
return System.Text.Encoding