|
Enhanced C#
Loyc library documentation
|
An implementation of ISyncManager for reading JSON objects. Designed to be both fast and flexible, this implementation normally reads UTF8 directly into values without allocating intermediate strings, and without requiring the entire JSON file to be loaded into memory at once. SupportsReordering, SupportsDeduplication and SupportsNextField are all true, and non-strict JSON is allowed (e.g. comments are accepted but ignored, unless you turn off support in the Options.) More...
An implementation of ISyncManager for reading JSON objects. Designed to be both fast and flexible, this implementation normally reads UTF8 directly into values without allocating intermediate strings, and without requiring the entire JSON file to be loaded into memory at once. SupportsReordering, SupportsDeduplication and SupportsNextField are all true, and non-strict JSON is allowed (e.g. comments are accepted but ignored, unless you turn off support in the Options.)
For best performance, your synchronizers should read the JSON data in the same order it was written. Synchronizers written in the usual way naturally work this way. Out-of-order reads are supported but are slower and, when reading large JSON files, may use more memory.
Since the JSON is always read in a single pass from an IScanner{byte}, trying to read a JSON property that doesn't exist can, in the worst case, cause the whole file to be buffered into memory. However, JSON files that are (essentially) large arrays won't have this problem, since you can only read arrays in order.
This type can read JSON files larger than 2GB, provided that an out-of- order read doesn't cause over 2GB of data to be scanned at once.
While normally you can read properties in any order, metadata properties such as $id and $ref must be located at the beginning of a JSON object in order to be detected during deserialization. (Newtonsoft.Json has the same restriction, by the way.) In addition, object IDs must always be represented by the same byte sequence, e.g. "3" and "\u0033" are not treated as the same ID even though they both represent "3" in JSON.
This is a struct rather than a class for performance reasons. Don't try to use a default(Reader); it'll throw NullReferenceException.
Properties | |
| object | CurrentObject [set] |
Public Member Functions | |
| bool int object Object | BeginSubObject (FieldId name, object?childKey, ObjectMode mode, int listLength=-1) |
| void | EndSubObject () |
| SyncType | GetFieldType (FieldId name, SyncType expectedType=SyncType.Unknown) |
| string | SyncTypeTag (string?tag) |
| bool | Sync (FieldId name, bool savable) |
| sbyte | Sync (FieldId name, sbyte savable) |
| byte | Sync (FieldId name, byte savable) |
| short | Sync (FieldId name, short savable) |
| ushort | Sync (FieldId name, ushort savable) |
| int | Sync (FieldId name, int savable) |
| uint | Sync (FieldId name, uint savable) |
| long | Sync (FieldId name, long savable) |
| ulong | Sync (FieldId name, ulong savable) |
| float | Sync (FieldId name, float savable) |
| double | Sync (FieldId name, double savable) |
| decimal | Sync (FieldId name, decimal savable) |
| BigInteger | Sync (FieldId name, BigInteger savable) |
| char | Sync (FieldId name, char savable) |
| int | Sync (FieldId name, int savable, int bits, bool signed=true) |
| long | Sync (FieldId name, long savable, int bits, bool signed=true) |
| BigInteger | Sync (FieldId name, BigInteger savable, int bits, bool signed=true) |
| List | SyncListBoolImpl< Scanner, List, ListBuilder > (FieldId name, Scanner scanner, List?saving, ListBuilder builder, ObjectMode mode, int tupleLength=-1) |
| List | SyncListByteImpl< Scanner, List, ListBuilder > (FieldId name, Scanner scanner, List?saving, ListBuilder builder, ObjectMode mode, int tupleLength=-1) |
| List | SyncListCharImpl< Scanner, List, ListBuilder > (FieldId name, Scanner scanner, List?saving, ListBuilder builder, ObjectMode mode, int tupleLength=-1) |
| bool | Sync (FieldId name, bool?savable) |
| sbyte | Sync (FieldId name, sbyte?savable) |
| byte | Sync (FieldId name, byte?savable) |
| short | Sync (FieldId name, short?savable) |
| ushort | Sync (FieldId name, ushort?savable) |
| int | Sync (FieldId name, int?savable) |
| uint | Sync (FieldId name, uint?savable) |
| long | Sync (FieldId name, long?savable) |
| ulong | Sync (FieldId name, ulong?savable) |
| float | Sync (FieldId name, float?savable) |
| double | Sync (FieldId name, double?savable) |
| decimal | Sync (FieldId name, decimal?savable) |
| BigInteger | Sync (FieldId name, BigInteger?savable) |
| char | Sync (FieldId name, char?savable) |
| string | Sync (FieldId name, string?savable, ObjectMode mode=ObjectMode.Normal) |
1.8.7