Doc/Codecs/JsonDataContracts

Using the JsonDataContractCodec

The JsonDataContractCodec provides JSON representations of resources.

Registering the codec

Whenever you want to render a resource using the JsonDataContractCodec, use the following form:

ResourceSpace.Has.ResourcesOfType<Customer>()
                 /* your handler declaration */
                 .AsJsonDataContract();

This is a shorthand version of the full codec registration:

ResourceSpace.Has.ResourcesOfType<Customer>()
                 /* your handler declaration */
                 .TranscodedBy<JsonDataContractCodec>(null)

Serialization Considerations

While it is not necessary to decorate the resource with System.Runtime.Serialization attributes such as DataContract and DataMember, doing so allows for much more control over the final rendered output.