CrystalJsonVisitor

Namespace: SnowBank.Data.Json · class

Internal helper to convert values into JSON strings

Methods

ConvertDictionaryToJson

static void ConvertDictionaryToJson(JsonObject root, IEnumerable<KeyValuePair<string, string>> wmlDictionary, char separator = '.')

ConvertTupleToJson

static JsonValue ConvertTupleToJson(IVarTuple tuple)

static JsonValue ConvertTupleToJson(ITuple tuple)

ConvertXmlNodeToJson

static JsonValue ConvertXmlNodeToJson(XmlNode node, bool flatten = false)

Convert an XmlNode into a JSON object or value

  • node — XML node to convert
  • flatten — If false, all XML attributes will be prefixed by '@'. If true, they will be mixed with the children of this node and could create conflicts

Child with the same name will be merged into an array.

ConvertXmlNodeToJson(<foo id="123"><bar>hello</bar><baz>world</baz></foo>) => { "foo": { "@id": "123", "bar": "hello", "baz": "world" } }

CreateVisitorForITupleType

static CrystalJsonTypeVisitor CreateVisitorForITupleType(Type type)

CreateVisitorForSTupleType

static CrystalJsonTypeVisitor CreateVisitorForSTupleType(Type type)

GetVisitorForType

static CrystalJsonTypeVisitor GetVisitorForType(Type type, bool atRuntime = false)

Return a visitor that is able to serialize instances of the specified type

  • type — Type as declared in the parent (compile time) or actual instance type (at runtime)
  • atRuntimefalse when performing the initial mapping (compile time), true when calling at runtime with the actual instance type

VisitArray

static void VisitArray<T>(T[] array, CrystalJsonWriter writer)

Visit an array of generic values

VisitCustomClassOrStruct

static void VisitCustomClassOrStruct(object value, Type declaringType, Type runtimeType, CrystalJsonWriter writer)

Visit a custom reference or value type

VisitDictionary

static void VisitDictionary(IDictionary dictionary, Type keyType, Type valueType, CrystalJsonWriter writer)

Visit a non-generic IDictionary

VisitDictionary_Int32Key

static void VisitDictionary_Int32Key(IDictionary dictionary, Type valueType, CrystalJsonTypeVisitor visitor, CrystalJsonWriter writer)

Visit a Dictionary<int, T>

VisitDictionary_Int32Key_StringValue

static void VisitDictionary_Int32Key_StringValue(IDictionary<int, string> dictionary, CrystalJsonWriter writer)

Visit a Dictionary<int, string>

VisitDictionary_StringKey

static void VisitDictionary_StringKey(IDictionary dictionary, Type valueType, CrystalJsonTypeVisitor visitor, CrystalJsonWriter writer)

Visit a non-generic IDictionary with keys known to be strings

VisitDictionary_StringKeyAndValue

static void VisitDictionary_StringKeyAndValue(IDictionary<string, string> dictionary, CrystalJsonWriter writer)

Visit a Dictionary<string, string>

VisitEnumerable

static void VisitEnumerable(IEnumerable enumerable, Type elementType, CrystalJsonWriter writer)

VisitEnumerableOfString

static void VisitEnumerableOfString(IEnumerable<string> enumerable, CrystalJsonWriter writer)

Visit a collection of strings

VisitGenericDictionary

static void VisitGenericDictionary<TValue>(ICollection<KeyValuePair<string, TValue>> items, CrystalJsonWriter writer)

Visit a Dictionary<string, object>

VisitGenericObjectDictionary

static void VisitGenericObjectDictionary(ICollection<KeyValuePair<string, object>> items, CrystalJsonWriter writer)

Visit a collection of KeyValuePair<string, object>

VisitITupleGeneric

static void VisitITupleGeneric(object value, Type declaredType, Type runtimeType, CrystalJsonWriter writer)

VisitJsonPackable

static void VisitJsonPackable(object value, Type declaringType, Type runtimeType, CrystalJsonWriter writer)

Visit a type that implements IJsonPackable

VisitJsonSerializable

static void VisitJsonSerializable(object value, Type declaringType, Type runtimeType, CrystalJsonWriter writer)

Visit a type that implements IJsonSerializable

VisitList

static void VisitList<T>(List<T> list, CrystalJsonWriter writer)

Visit an array of generic values

VisitSTuple1

static void VisitSTuple1<T1>(object tuple, Type declaredType, Type runtimeType, CrystalJsonWriter writer)

Visit a tuple of length 1

VisitSTuple2

static void VisitSTuple2<T1, T2>(object tuple, Type declaredType, Type runtimeType, CrystalJsonWriter writer)

Visit a tuple of length 2

VisitSTuple3

static void VisitSTuple3<T1, T2, T3>(object tuple, Type declaredType, Type runtimeType, CrystalJsonWriter writer)

Visit a tuple of length 3

VisitSTuple4

static void VisitSTuple4<T1, T2, T3, T4>(object tuple, Type declaredType, Type runtimeType, CrystalJsonWriter writer)

Visit a tuple of length 4

VisitSTuple5

static void VisitSTuple5<T1, T2, T3, T4, T5>(object tuple, Type declaredType, Type runtimeType, CrystalJsonWriter writer)

Visit a tuple of length 5

VisitSTuple6

static void VisitSTuple6<T1, T2, T3, T4, T5, T6>(object tuple, Type declaredType, Type runtimeType, CrystalJsonWriter writer)

Visit a tuple of length 6

VisitSTuple7

static void VisitSTuple7<T1, T2, T3, T4, T5, T6, T7>(object tuple, Type declaredType, Type runtimeType, CrystalJsonWriter writer)

Visit a tuple of length 7

VisitSTuple8

static void VisitSTuple8<T1, T2, T3, T4, T5, T6, T7, T8>(object tuple, Type declaredType, Type runtimeType, CrystalJsonWriter writer)

Visit a tuple of length 8

VisitSTupleGeneric

static void VisitSTupleGeneric(object value, Type declaredType, Type runtimeType, CrystalJsonWriter writer)

Visit a boxed tuple

VisitSpan

static void VisitSpan<T>(ReadOnlySpan<T> items, CrystalJsonWriter writer)

Visit an array of generic values

VisitStringDictionary

static void VisitStringDictionary(ICollection<KeyValuePair<string, string>> items, CrystalJsonWriter writer)

Visit a Dictionary<string, string>

VisitValue

static void VisitValue<T>(T value, CrystalJsonWriter writer)

Visit a generic value

static void VisitValue(object value, Type declaredType, CrystalJsonWriter writer)

Visit a boxed value (Primitive, ValueType, Class, Struct, ...)

  • value — Value that needs to be serialized (could be of any type)
  • declaredType — Type of this value as declared in the containing type, or null if unknown or top-level
  • writer — Serialization context

VisitValueTuple1

static void VisitValueTuple1<T1>(object tuple, Type declaredType, Type runtimeType, CrystalJsonWriter writer)

Visit a boxed ValueTuple of length 1

VisitValueTuple2

static void VisitValueTuple2<T1, T2>(object tuple, Type declaredType, Type runtimeType, CrystalJsonWriter writer)

Visit a boxed ValueTuple of length 2

VisitValueTuple3

static void VisitValueTuple3<T1, T2, T3>(object tuple, Type declaredType, Type runtimeType, CrystalJsonWriter writer)

Visit a boxed ValueTuple of length 3

VisitValueTuple4

static void VisitValueTuple4<T1, T2, T3, T4>(object tuple, Type declaredType, Type runtimeType, CrystalJsonWriter writer)

Visit a boxed ValueTuple of length 4

VisitValueTuple5

static void VisitValueTuple5<T1, T2, T3, T4, T5>(object tuple, Type declaredType, Type runtimeType, CrystalJsonWriter writer)

Visit a boxed ValueTuple of length 5

VisitValueTuple6

static void VisitValueTuple6<T1, T2, T3, T4, T5, T6>(object tuple, Type declaredType, Type runtimeType, CrystalJsonWriter writer)

Visit a boxed ValueTuple of length 6

VisitValueTuple7

static void VisitValueTuple7<T1, T2, T3, T4, T5, T6, T7>(object tuple, Type declaredType, Type runtimeType, CrystalJsonWriter writer)

Visit a boxed ValueTuple of length 7

VisitValueTuple8

static void VisitValueTuple8<T1, T2, T3, T4, T5, T6, T7, T8>(object tuple, Type declaredType, Type runtimeType, CrystalJsonWriter writer)

Visit a boxed ValueTuple of length 7

VisitXmlNode

static void VisitXmlNode(XmlNode node, CrystalJsonWriter writer)

Visit an XmlNode