Serializing Configuration#
RTA provides two configuration formats:
- JSON (
application/vnd.mat.config+json
) - FFC (
application/vnd.mat.config+ffc
)
JSON#
The JSON format is defined in the JSON schema.
JSON Conventions
- Properties can be omitted if they are
null
or empty arrays/maps - Properties are camelCase — e.g.
"timeRange"
instead of"TimeRange"
- Enumerations are expressed as camelCase string constants — e.g.
"closed"
instead of"Closed"
For .NET, library support is provided via McLaren's NuGet packages.
To convert configuration to JSON, add a package reference for MAT.OCS.Configuration.Json and use the serializer like this:
using MAT.OCS.Configuration.Json;
using Newtonsoft.Json;
var json = JsonConvert.SerializeObject(config, Formatting.Indented, new ConfigurationJsonConverter());
When publshing to the Config Service, the MAT.OCS.RTA.Toolkit.API.GrpcClients package handles JSON serialization automatically:
using MAT.OCS.RTA.Toolkit.API.ConfigService;
// handles serialization automatically
await configClient.PutConfigAsync(configIdentifier, config, MediaTypes.JsonConfig);
FFC#
FFC is a McLaren proprietary binary format with support for internal indexing and selective parsing.
It is supported in C#, F#, C++ VB.NET for .NET Core and .NET Framework, via McLaren's NuGet packages.
If you are using another language, serialize configuration as JSON.
Info
This is the default format when publishing to the Config Service using the MAT.OCS.RTA.Toolkit.API.GrpcClients package.
To serialize to FFC explicitly, add a package reference for MAT.OCS.FFC.ConfigSerializer and use the serializer like this:
using MAT.OCS.FFC.ConfigSerializer;
await using var ms = new MemoryStream();
FastConfigSerializer.Serialize(config, "RTA", identifier).ToStream(ms);
var ffc = ms.ToArray();
When publshing to the Config Service, the MAT.OCS.RTA.Toolkit.API.GrpcClients package handles FFC serialization automatically::
using MAT.OCS.RTA.Toolkit.API.ConfigService;
// handles serialization automatically
await configClient.PutConfigAsync(configIdentifier, config);