Package org.apache.juneau.bean.jsonapi
@Marshalled types for the
JSON:API v1.1 wire format.
Overview
JSON:API is a media-type (application/vnd.api+json) for building APIs with shared conventions for
resources, relationships, links, errors, and metadata. This module provides typed Juneau beans modeling the
JSON:API wire format - no marshaller is needed; the existing JsonSerializer /
JsonParser already produce and consume the wire format. The matching
ContentType constant is org.apache.juneau.http.header.ContentType#APPLICATION_VND_API_JSON.
Bean Classes
JsonApiDocument- Top-level container withdata/errors/meta/jsonapi/links/included.JsonApiResource- Resource object withtype/id/attributes/relationships/links/meta.JsonApiResourceIdentifier- Slim form used inside relationship linkage.JsonApiRelationship- Relationship object (datalinkage,links,meta).JsonApiError- Error object withid/links/status/code/title/detail/source/meta.JsonApiErrorSource- Thesourcesub-object (pointer/parameter/header).JsonApiLink- Link object withhref/rel/describedby/title/type/hreflang/meta.JsonApiVersion- Thejsonapimember (version/meta).JsonApiLinkOrStringSwap-ObjectSwapforlinksmap values; each value can be either a JSON string URL or aJsonApiLinkobject per the spec.
Important: JsonApiResource.type is a plain String
JSON:API uses type as an open-ended string field on resource objects (the entity-type name, e.g.
"articles"); the value is chosen by the API and is not a closed Java class hierarchy. Therefore
JsonApiResource models type as a plain String and is not annotated with
@Marshalled(typePropertyName="type", dictionary=...). Conflating JSON:API resource typing with Juneau
bean dispatch would break round-tripping of unknown type values and force every API to enumerate its
resource types in a Java dictionary up front.
Document-level mutual exclusion
Per the JSON:API spec, a document MUST contain at least one of data, errors, or meta;
data and errors MUST NOT coexist. JsonApiDocument
documents this constraint and offers an optional validate() helper.
Example
See Also:
-
ClassesClassDescriptionRepresents the top-level JSON:API document as defined by JSON:API v1.1 § Document Structure.Represents a JSON:API Error Object as defined by JSON:API v1.1 § Error Objects.Represents the
sourcesub-object of a JSON:API Error Object.Represents a JSON:API Link Object as defined by JSON:API v1.1 § Links.Per-propertyObjectSwapapplied to JSON:APIlinksmaps so that each map entry round-trips as either a JSON string URL or aJsonApiLinkJSON object per the spec.Represents a JSON:API Relationship Object as defined by JSON:API v1.1 § Relationships.Represents a JSON:API Resource Object as defined by JSON:API v1.1 § Resource Objects.Represents a JSON:API Resource Identifier Object as defined by JSON:API v1.1 § Resource Identifier Objects.Represents the JSON:API top-leveljsonapimember.