Class XmlJsonDataFormat
XML to JSON and back without a class, as Apache Camel's xmljson: Marshal turns an XML body into JSON,
Unmarshal turns a JSON body into XML (or, to a , an XML body into the JSON tree). The
notation is Json.NET's (, #text); which elements are arrays comes from the schema, the arrays
paths, the opt-in plural rule, and otherwise from the document itself (a repeat is an array).
When a class exists for the document, the typed path stays the recommended one: Unmarshal<Order>() from
XML, then Marshal() to JSON.
The schema path resolves through the route context's resource resolver, as validateXsd does, on the first
message of each context; the compiled schema is kept for that context.
public sealed class XmlJsonDataFormat : IMessageDataFormat, IMessageSerializer
Inheritance
Implements
Properties
ContentType
Content type this serializer handles (e.g., "application/json").
public string ContentType { get; }
MediaTypes
All media types this serializer can handle, including structured-suffix aliases
public IReadOnlyCollection<string> MediaTypes { get; }
Prefixes
Namespace prefixes, comma-separated prefix=uri pairs: o=urn:orders ().
public string? Prefixes { get; set; }
SchemaRoot
The directory imports may read from, relative to the schema's directory ().
public string? SchemaRoot { get; set; }
WrapsBytes
true for a format whose input is raw bytes rather than an object model (Base64, GZip, Zip):
public bool WrapsBytes { get; }
Methods
Deserialize(byte[], Type)
Without a route context: JSON to XML as type (string, byte[],
public object? Deserialize(byte[] data, Type type)
Deserialize<T>(byte[])
Deserializes a byte array to a typed value.
public T? Deserialize<T>(byte[] data)
MarshalAsync(IExchange, CancellationToken)
Turns the body of exchange.In (and its attachments, when the format carries them) into the wire form, in place.
public ValueTask MarshalAsync(IExchange exchange, CancellationToken ct = default)
Serialize<T>(T)
XML to JSON, without a route context: the schema path resolves through the default resolver.
public byte[] Serialize<T>(T value)
UnmarshalAsync(IExchange, Type, CancellationToken)
Turns the wire form in exchange.In into targetType, in place.
public ValueTask UnmarshalAsync(IExchange exchange, Type targetType, CancellationToken ct = default)
Constructors
XmlJsonDataFormat()
Creates the format with default options; markup sets its properties.
XmlJsonDataFormat(XmlJsonOptions?)
Creates the format with the given options (defaults when null).