CDP4JsonSerializer Overview - STARIONGROUP/COMET-SDK-Community-Edition GitHub Wiki
Introduction
The CDP4JsonSerializer library is used to serialize and deserialize the classess that are defined in the [COMET 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 COMET-IME and the COMET® Web Services.
IMetaDataProvider and Version
The COMET Data Model is an extension of ECSS-E-TM-10-25A-Annex-A where CDP4-COMET specific Classes and properties have been added. The CDP4-COMET 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-COMET 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-COMET 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));