C# 클래스 Jayrock.Json.FreeJsonMemberReadingHelper

Helps reading JSON members from an underlying JsonReader without regard to the order (free) in which they appear. Members are buffered or streamed as needed.
A JsonReader has a stream-oriented interface where the underlying JSON data is tokenized and yielded sequentially. When reading a JSON object, members must be processed in the order in which they are yielded by the underlying reader. If an application requires some members of a JSON object to correctly process the remaining members then those member may need to be read in advance to prepare for further processing. For example, suppose the JSON object { "type": "date", "format": "M/d/yyyy", "value": "5/5/2008" } represents a date encoded in the value member as a JSON string. Suppose further, the type confirms that the entire JSON object indeed describes a date and the format member specifies how to interpret the value member. To correctly create the date, an application would have to assert the type member, then read the format member to determine how to decode the value member value correctly. If the application assumes that the members are always provided in the natural order just described then it can simply use a JsonReader and process them in sequence along with their values. However, if the JSON object instead has members out of order, as in { "value": "5/5/2008", "type": "date", "format": "M/d/yyyy" }, then reading becomes a bit more cumbersome. The application would have to buffer the value and format member values until it has at least seen the type member and asserted its value to be date. Then it has to return to the buffered value of the format member and use it to finally decode the also-buffered value member. This is where FreeJsonMemberReadingHelper can help tremendously. The application can call its ReadMember method to read members in the natural order of processing (e.g., type, format and value) rather than how they have been actually ordered by some source. FreeJsonMemberReadingHelper will buffer or stream from the underlying JsonReader as needed. Once the required members have been processed, the GetTailReader method can be used to read auxillary or optional members in their order of appearance.
파일 보기 프로젝트 열기: atifaziz/Jayrock 1 사용 예제들

Private Properties

프로퍼티 타입 설명
TryPopBufferedMember JsonBuffer

공개 메소드들

메소드 설명
FreeJsonMemberReadingHelper ( Jayrock.Json.JsonReader reader ) : System
GetTailReader ( ) : Jayrock.Json.JsonReader

Gets a reader than can be used to read remaining members, which could include buffered and non-buffered members.

ReadMember ( string name ) : Jayrock.Json.JsonReader

Reads a member with a given (case-sensitive) name and returns a JsonReader that can be used to read the value. Otherwise it throws an exception.

The caller should not use the returned JsonReader instance for any other purpose but reading the value. It is possible that this method will return the same instance as BaseReader or a separate instance.

ToString ( ) : string

Returns the same string returned by the JsonReader.ToString implementation of BaseReader.

TryReadMember ( string name ) : Jayrock.Json.JsonReader

Attempts to locate a member with a given (case-sensitive) name and returns a JsonReader that can be used to read the value. Otherwise it returns null.

The caller should not use the returned JsonReader instance for any other purpose but reading the value. It is possible that this method will return the same instance as BaseReader or a separate instance.

비공개 메소드들

메소드 설명
TryPopBufferedMember ( string name ) : JsonBuffer

메소드 상세

FreeJsonMemberReadingHelper() 공개 메소드

public FreeJsonMemberReadingHelper ( Jayrock.Json.JsonReader reader ) : System
reader Jayrock.Json.JsonReader
리턴 System

GetTailReader() 공개 메소드

Gets a reader than can be used to read remaining members, which could include buffered and non-buffered members.
public GetTailReader ( ) : Jayrock.Json.JsonReader
리턴 Jayrock.Json.JsonReader

ReadMember() 공개 메소드

Reads a member with a given (case-sensitive) name and returns a JsonReader that can be used to read the value. Otherwise it throws an exception.
The caller should not use the returned JsonReader instance for any other purpose but reading the value. It is possible that this method will return the same instance as BaseReader or a separate instance.
/// A member with the requested name was not found. ///
public ReadMember ( string name ) : Jayrock.Json.JsonReader
name string
리턴 Jayrock.Json.JsonReader

ToString() 공개 메소드

Returns the same string returned by the JsonReader.ToString implementation of BaseReader.
public ToString ( ) : string
리턴 string

TryReadMember() 공개 메소드

Attempts to locate a member with a given (case-sensitive) name and returns a JsonReader that can be used to read the value. Otherwise it returns null.
The caller should not use the returned JsonReader instance for any other purpose but reading the value. It is possible that this method will return the same instance as BaseReader or a separate instance.
public TryReadMember ( string name ) : Jayrock.Json.JsonReader
name string
리턴 Jayrock.Json.JsonReader