Skip to content

CDP4JsonSerializer Overview

samatrhea edited this page Mar 15, 2020 · 5 revisions

Introduction

The CDP4JsonSerializer library is used to serialize and deserialize the classess that are defined in the CDP4 Data Model. It makes use of the popular high-performance JSON framework for .NET Json.NET to process JSON. The CDP4JsonSerializer library exposes ICdp4JsonSerializer interface and Cdp4JsonSerializer class that can be used to serialize or deserialize any object. It the objects are DTO objects or a Classless-DTO the CDP4JsonSerializer makes used of optimized serialization and deserialization code that does not rely on reflection but on hard coded mappings between the properties of the classes and properties of JSON objects.

The CDP4JsonSerializer is used by the CDP4-IME and the CDP4® Web Services.

IMetaDataProvider and Version

The CDP4 Data Model is an extension of ECSS-E-TM-10-25A-Annex-A where CDP4® specific Classes and properties have been added. The CDP4® extensions, both classes and extra properties on existing classes, have been modelled in the UML master model and have been decorated with a CDPVersion stereotype.

The CDP4JsonSerializer makes it possible to include or excluded CDP4® specific properties when serializing or deserializing DTO objects. This is achieved by initializing the CDP4JsonSerializer with the IMetaDataProvider and a Version parameter. The classes and properties that are smaller than or equal to the specified Version will be included in the (de)serialization process, the others are excluded.

The following code snippet instantiates the Cdp4JsonSerializer with version 1.0.0 which is plain ECSS-E-TM-10-25A-Annex-A. The serialize method will not incldue any CDP4® specific data-types or properties that have been added to the meta-model.

var metaDataProvider = new MetaDataProvider();
var serializer = new Cdp4JsonSerializer(metaDataProvider, new Version(1, 0, 0));
Clone this wiki locally