WisejSerializer
Namespace: Wisej.Core
Assembly: Wisej.Framework (4.1.0.0)
Wisej super performant JSON serializer. This is a high performant and low memory footprint JSON serializer/deserializer. It has been optimized to work with Wisej DynamicObject and to streamline serialization/deserialization. It appears to be the fastest JSON serializer/deserializer using the least memory.
- C#
- VB.NET
public static class WisejSerializer
Public Class WisejSerializer
Properties
MaxDepth
Int32: Gets or sets the default maximum nesting depth when parsing JSON. The default is 32.
Each object or array adds one level; a root object or array has depth one. The value must be positive and is captured once at the start of each parse or field lookup.
Throws:
- ArgumentOutOfRangeException The value is less than one.
Methods
Parse(json)
Deserializes a JSON string to a System.Wisej.Core.DynamicObject.
| Parameter | Type | Description |
|---|---|---|
| json | String | The JSON source string. |
Returns: Object. A DynamicObject representing the JSON data.
Throws:
- FormatException The nesting depth exceeds MaxDepth.
Parse(stream)
Deserializes a JSON stream to a System.Wisej.Core.DynamicObject.
| Parameter | Type | Description |
|---|---|---|
| stream | Stream | The JSON source stream. |
Returns: Object. A DynamicObject representing the JSON data.
Throws:
- FormatException The nesting depth exceeds MaxDepth.
ReadField(data, fieldName)
Reads a named field from the root JSON object without constructing the full object graph.
| Parameter | Type | Description |
|---|---|---|
| data | String | The JSON source string. |
| fieldName | String | The case-sensitive root field name. |
Returns: Object. The parsed field value, or null if the field is absent or its value is null.
Uses the same value conversions and depth limit as Parse. Unselected containers are scanned iteratively. The entire root object is scanned to reject duplicate occurrences of the requested field, including those after its first value. Null or empty data returns null. This method does not impose a message-size limit.
Throws:
- ArgumentException The field name is null or empty.
- FormatException The root is not an object, the requested field occurs more than once, the depth limit is exceeded, or the JSON structure is incomplete.
Serialize(value, options)
Serializes an object to standard JSON.
| Parameter | Type | Description |
|---|---|---|
| value | Object | Value to serialize to JSON. |
| options | WisejSerializerOptions | Serializer options. |
Returns: String. The JSON representation of value .