Class JsonApiDocument

java.lang.Object
org.apache.juneau.bean.jsonapi.JsonApiDocument

@Marshalled public class JsonApiDocument extends Object
Represents the top-level JSON:API document as defined by JSON:API v1.1 § Document Structure.

Carries the standard six top-level members: data, errors, meta, jsonapi, links, included.

Mutual exclusion

Per spec, a document MUST contain at least one of data/errors/meta, and data and errors MUST NOT coexist. The validate() helper checks both rules and throws IllegalStateException on violation.

The polymorphic data member

The top-level data can be null, a single JsonApiResource, or an array of them. We model data as a plain Object property; the writer chooses single-vs-array shape based on which value was set. Typed setters setData(JsonApiResource) and setData(List) are provided for convenience.

See Also: