|
Enhanced C#
Loyc library documentation
|
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...
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.
Reader and Writer do not make a copy of this object before using it, so for the most part it is possible to change these options after constructing the reader/writer and have those changes take effect somewhere in the middle of a JSON object. However, certain options are cached for performance reasons, e.g. Writer caches the UTF-8 version of Options.ForWriter.Indent and Options.ForWriter.Newline during initialization, and therefore will not notice if these properties change later.
Nested classes | |
| class | ForReader |
| class | ForWriter |
Properties | |
| bool | NewtonsoftCompatibility [get, set] |
| If true, Newtonsoft-style special fields "$id" and "$ref" will be used for deduplication and resolution of circular references, and byte arrays are encoded in Base64. If false, more compact SyncLib-style references and BAIS encoding are used instead. More... | |
| Func< string, string > | NameConverter = true [get, set] |
| A function for altering names used in the first argument of ISyncManager.Sync. To use camelCase, set this to SyncJson.ToCamelCase. More... | |
| ObjectMode | RootMode [get, set] |
| The ObjectMode used to read/write the root object. This option has no effect if you are using NewWriter or NewReader. More... | |
| JsonByteArrayMode | ByteArrayMode = ObjectMode.Normal [get, set] |
| When NewtonsoftCompatibility is off, this property controls the way byte arrays and byte lists are written. In special cases it can also affect the way reading happens (see Remarks). When writing with NewtonsoftCompatibility enabled, Base64 is written instead of BAIS. More... | |
| ForWriter | Write = JsonByteArrayMode.PrefixedBais [get, set] |
| ForReader | Read [get, set] |
Public Member Functions | |
| Options (bool compactMode=false) | |
|
getset |
When NewtonsoftCompatibility is off, this property controls the way byte arrays and byte lists are written. In special cases it can also affect the way reading happens (see Remarks). When writing with NewtonsoftCompatibility enabled, Base64 is written instead of BAIS.
The documentation of JsonByteArrayMode explains each mode. Generally, ByteArrayMode.PrefixedBais mode is recommended for the most compact output and best debugging experience (since BIAS preserves long runs of ASCII characters in the output), but Base64 is required for Newtonsoft compatibility.
Therefore, when NewtonsoftCompatibility is on, the BAIS modes are treated as Base64. In addition, Newtonsoft writes byte lists (List<byte>) as JSON arrays, so SyncJson.Writer replicates this behavior too.
When reading a byte array, the encoding is normally autodetected and the value of this property is not important. However, if the JSON contains a string, and NewtonsoftCompatibility is off, and the string does not start with '!' or '' (both of which indicate BAIS encoding), it is unclear whether the string is BAIS or Base64. In this case, the string is interpreted as Base64 unless the mode is set to JsonByteArrayMode.Bais.
Therefore, from a backward compatibility standpoint, switching from JsonByteArrayMode.Bais to JsonByteArrayMode.PrefixedBais mode is a backward compatibility hazard as SyncJson.Reader may try to interpret an unprefixed BAIS string as Base64. However, any other mode change is safe, because data previously written will contain enough information to detect the data format.
|
getset |
A function for altering names used in the first argument of ISyncManager.Sync. To use camelCase, set this to SyncJson.ToCamelCase.
|
getset |
If true, Newtonsoft-style special fields "$id" and "$ref" will be used for deduplication and resolution of circular references, and byte arrays are encoded in Base64. If false, more compact SyncLib-style references and BAIS encoding are used instead.
|
getset |
The ObjectMode used to read/write the root object. This option has no effect if you are using NewWriter or NewReader.
1.8.7