Enhanced C#
Loyc library documentation
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
Nested classes | Static Public Member Functions | List of all members
SyncJson Class Reference

Source files:

Nested classes

class  Options
 Options that control general behavior of SyncJson.Reader and SyncJson.Writer. Note: some behaviors such as deduplication (including support for cyclic references) are controlled at the level of individual fields, and such options are not duplicated here. More...
 
struct  Reader
 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...
 
struct  SchemaWriter
 An implementation of ISyncManager that produces a JSON Schema (draft 2020-12) describing the JSON that SyncJson.Writer would produce with the same synchronizer and Options — including the effects of options such as Options.NameConverter, Options.NewtonsoftCompatibility and Options.ByteArrayMode, and the "$id"/"$ref" markers used when ObjectMode.Deduplicate is used. More...
 
struct  Writer
 An optimized implementation of ISyncManager for writing JSON objects. SupportsReordering and SupportsDeduplication are both true. More...
 

Static Public Member Functions

static string ToCamelCase (string name)
 Converts a string to camelCase format, e.g. "FileSize" => "fileSize" and "SQLQuery" => "sqlQuery". Assignable to Options.NameConverter. More...
 
static SyncJson.Reader NewReader (IScanner< byte > input, Options?options=null)
 
static SyncJson.Reader NewReader (ReadOnlyMemory< byte > input, Options?options=null)
 
static SyncJson.Reader NewReader (string input, Options?options=null)
 
static T Read< T > (ReadOnlyMemory< byte > json, SyncObjectFunc< Reader, T > sync, Options?options=null)
 
static T ReadI< T > (ReadOnlyMemory< byte > json, SyncObjectFunc< ISyncManager, T > sync, Options?options=null)
 
static T Read< T, SyncObject > (ReadOnlyMemory< byte > input, SyncObject sync, Options?options=null)
 
static T Read< T > (string json, SyncObjectFunc< Reader, T > sync, Options?options=null)
 
static T ReadI< T > (string json, SyncObjectFunc< ISyncManager, T > sync, Options?options=null)
 
static T Read< T, SyncObject > (string json, SyncObject sync, Options?options=null)
 
static SchemaWriter NewSchemaWriter (Options?options=null)
 Creates a SyncJson.SchemaWriter, an object for saving a JSON Schema that describes the JSON produced by SyncJson.Writer. After using it to "synchronize" one root object, call SchemaWriter.Finish (or ToString) to get the schema document. More...
 
static ReadOnlyMemory< byte > WriteSchema< T > (SyncObjectFunc< SchemaWriter, T > sync, Options?options=null)
 Generates a JSON Schema (draft 2020-12, UTF-8) describing the JSON that SyncJson.Write{T}(T, SyncObjectFunc{Writer, T}, Options?) produces for type T with the same synchronizer and options. More...
 
static ReadOnlyMemory< byte > WriteSchemaI< T > (SyncObjectFunc< ISyncManager, T > sync, Options?options=null)
 
static ReadOnlyMemory< byte > WriteSchema< T, SyncObject > (SyncObject sync, Options?options=null)
 
static string WriteSchemaString< T > (SyncObjectFunc< SchemaWriter, T > sync, Options?options=null)
 
static string WriteSchemaStringI< T > (SyncObjectFunc< ISyncManager, T > sync, Options?options=null)
 
static string WriteSchemaString< T, SyncObject > (SyncObject sync, Options?options=null)
 
static SyncJson.Writer NewWriter (IBufferWriter< byte >?output=null, Options?options=null)
 
static ReadOnlyMemory< byte > Write< T > (T value, SyncObjectFunc< Writer, T > sync, Options?options=null)
 
static ReadOnlyMemory< byte > WriteI< T > (T value, SyncObjectFunc< ISyncManager, T > sync, Options?options=null)
 
static ReadOnlyMemory< byte > Write< T, SyncObject > (T value, SyncObject sync, Options?options=null)
 
static string WriteString< T > (T value, SyncObjectFunc< Writer, T > sync, Options?options=null)
 
static string WriteStringI< T > (T value, SyncObjectFunc< ISyncManager, T > sync, Options?options=null)
 
static string WriteString< T, SyncObject > (T value, SyncObject sync, Options?options=null)
 

Member Function Documentation

static SchemaWriter SyncJson.NewSchemaWriter ( Options options = null)
static

Creates a SyncJson.SchemaWriter, an object for saving a JSON Schema that describes the JSON produced by SyncJson.Writer. After using it to "synchronize" one root object, call SchemaWriter.Finish (or ToString) to get the schema document.

Referenced by WriteSchema< T >(), WriteSchema< T, SyncObject >(), and WriteSchemaI< T >().

static string SyncJson.ToCamelCase ( string  name)
inlinestatic

Converts a string to camelCase format, e.g. "FileSize" => "fileSize" and "SQLQuery" => "sqlQuery". Assignable to Options.NameConverter.

static ReadOnlyMemory<byte> SyncJson.WriteSchema< T > ( SyncObjectFunc< SchemaWriter, T >  sync,
Options options = null 
)
inlinestatic

Generates a JSON Schema (draft 2020-12, UTF-8) describing the JSON that SyncJson.Write{T}(T, SyncObjectFunc{Writer, T}, Options?) produces for type T with the same synchronizer and options.

The synchronizer function runs once in SyncMode.Schema mode, in which there is no data: the function receives a default/null value of T, and the Sync methods return default values. Fields that the function only synchronizes conditionally are recorded only if the condition happens to be true when given default values.

References NewSchemaWriter().