Show / Hide Table of Contents

Class Converter

The converter is used to serialize a C# conizi model to JSON or deserialize JSON to a C# model

Inheritance
System.Object
Converter
Namespace: Conizi.Model.Core.Tools
Assembly: Conizi.Model.Core.dll
Syntax
public static class Converter : object

Methods

Deserialize(String)

Deserialize a JSON file to an instance of a C# model.

Declaration
public static IModel Deserialize(string json)
Parameters
Type Name Description
System.String json

The JSON content as string

Returns
Type Description
Conizi.Model.Shared.Interfaces.IModel

IModel instance, could be cast into the right type if necessary

Deserialize<TModel>(String)

Deserialize a JSON file to an instance of a C# model.

Declaration
public static TModel Deserialize<TModel>(string json)
    where TModel : EdiModel
Parameters
Type Name Description
System.String json

The JSON content as string

Returns
Type Description
TModel

Instance of the set model type

Type Parameters
Name Description
TModel

The target C# model in which the JSON is to be deserialized

Examples

Deserialize JSON to C# TourEvent model instance.

var m = Converter.Deserialize<TourEvent>(content);

Serialize<TModel>(TModel, Boolean, Boolean, Boolean)

Serialize a C# model instance to JSON

Declaration
public static SerializationResult Serialize<TModel>(TModel model, bool indented = false, bool ignoreValidation = false, bool writeMetadata = false)
    where TModel : EdiModel
Parameters
Type Name Description
TModel model

The instance of the model, should be serialized

System.Boolean indented

Should the content well formatted?

System.Boolean ignoreValidation

Ignore the validation after serialization. May be helpful if no JSON Schema license is available

System.Boolean writeMetadata
Returns
Type Description
SerializationResult

Instance of SerializationResult

Type Parameters
Name Description
TModel

The model type should be serialized

Examples

Serialize a model instance to JSON.

var result = Converter.Serialize(m);
Back to top Generated by DocFX