Class JsonApiDocument

Namespace
Subsembly.Json
Assembly
Subsembly.Json.dll

Represents a JSON API Document returned from a JSON API REST endpoint.

public class JsonApiDocument : JsonObject, ICloneable
Inheritance
JsonApiDocument
Implements
Inherited Members

Constructors

JsonApiDocument(IJsonApiObjectFactory)

public JsonApiDocument(IJsonApiObjectFactory aObjectFactory)

Parameters

aObjectFactory IJsonApiObjectFactory

Optional object factory that will be used the create the resource objects that may be contained in this document. If this is null, then a plain JsonObject will be used for resource objects.

Properties

DataAsArray

Provides the JSON API document data as a JSON array.

public JsonApiResourceObject[] DataAsArray { get; }

Property Value

JsonApiResourceObject[]

Remarks

If the actual JSON API document data is a JSON array, then this property provides that array data. If the actual JSON API document data is a single JSON object, then this property returns an array containing that single object. In all other cases an empty array is returned. null.

DataAsObject

If the JSON API document data is represented as single JSON object, then this property provides that object.

public JsonApiResourceObject DataAsObject { get; }

Property Value

JsonApiResourceObject

Remarks

If the JSON API document data is a JSON array, then this property is null.

DataCount

Returns the number of resource objects provided through the "data" field.

public int DataCount { get; }

Property Value

int

Errors

public JsonApiErrorObjects Errors { get; }

Property Value

JsonApiErrorObjects

Included

public JsonApiResourceObjects Included { get; }

Property Value

JsonApiResourceObjects

JsonApi

public JsonApiVersionObject JsonApi { get; }

Property Value

JsonApiVersionObject

Meta

public JsonObject Meta { get; }

Property Value

JsonObject

Version

Provides the JSON API version from the JsonApi object.

public string Version { get; }

Property Value

string

Remarks

If there is no JsonApi object, then the default "1.0" is returned.

Methods

FindIncluded(string, string)

public JsonApiResourceObject FindIncluded(string sType, string sId)

Parameters

sType string
sId string

Returns

JsonApiResourceObject

OnCreateChildArray(string)

protected override JsonArray OnCreateChildArray(string sFieldName)

Parameters

sFieldName string

Returns

JsonArray

OnCreateChildObject(string)

protected override JsonObject OnCreateChildObject(string sFieldName)

Parameters

sFieldName string

Returns

JsonObject

Remarks

The default implementation creates a JsonApiResourceObject for the "data" object. An override may create a more specialized type derived from JsonApiResourceObject.

The default implementation creates a plain JsonObject for the "meta" object. An override may create a more spezialized type.