Class: JsonApiSerializer
jsonapi.JsonApiSerializer
Serializer implementation for JSON:API.
Hierarchy
ObjectSerializer
<JsonApiDocument
>↳
JsonApiSerializer
Constructors
constructor
• new JsonApiSerializer(config?
)
Parameters
Name | Type |
---|---|
config? | ObjectSerializerConfig |
Inherited from
Defined in
src/object/objectSerializer.ts:19
Methods
configure
▸ configure(config?
, override?
): void
Parameters
Name | Type | Default value |
---|---|---|
config? | ObjectSerializerConfig | undefined |
override | boolean | true |
Returns
void
Inherited from
Defined in
src/object/objectSerializer.ts:23
hydrateAttributeInResource
▸ Protected
hydrateAttributeInResource(resource
, serializedKey
, serializedValue
): Promise
<void
>
Parameters
Name | Type |
---|---|
resource | JsonApiDocument |
serializedKey | string |
serializedValue | unknown |
Returns
Promise
<void
>
Inherit Doc
Overrides
ObjectSerializer.hydrateAttributeInResource
Defined in
src/jsonapi/jsonApiSerializer.ts:26
hydratePropInResource
▸ Protected
hydratePropInResource(_resource
, _serializedKey
, _serializedValue
): Promise
<void
>
Parameters
Name | Type |
---|---|
_resource | JsonApiDocument |
_serializedKey | string |
_serializedValue | unknown |
Returns
Promise
<void
>
Inherited from
ObjectSerializer.hydratePropInResource
Defined in
src/object/objectSerializer.ts:72
hydrateRelationInResource
▸ Protected
hydrateRelationInResource(resource
, serializedKey
, serializedValue
): Promise
<void
>
Parameters
Name | Type |
---|---|
resource | JsonApiDocument |
serializedKey | string |
serializedValue | unknown |
Returns
Promise
<void
>
Inherit Doc
Overrides
ObjectSerializer.hydrateRelationInResource
Defined in
src/jsonapi/jsonApiSerializer.ts:39
makeResource
▸ Protected
makeResource(instance
): Promise
<{ data
: { attributes
: {} = {}; id
: undefined
| string
; lid
: undefined
| string
; relationships
: {} = {}; type
: string
= instance.$model.$type } }>
Parameters
Name | Type |
---|---|
instance | ModelInstance |
Returns
Promise
<{ data
: { attributes
: {} = {}; id
: undefined
| string
; lid
: undefined
| string
; relationships
: {} = {}; type
: string
= instance.$model.$type } }>
Inherit Doc
Overrides
Defined in
src/jsonapi/jsonApiSerializer.ts:13
serialize
▸ serialize(instance
, context
): Promise
<JsonApiDocument
>
Parameters
Name | Type |
---|---|
instance | ModelInstance |
context | Object |
Returns
Promise
<JsonApiDocument
>
Inherited from
Defined in
src/object/objectSerializer.ts:27
serializeAttributeKey
▸ Protected
serializeAttributeKey(instance
, def
, _context
): Promise
<string
>
Parameters
Name | Type |
---|---|
instance | ModelInstance |
def | ModelAttribute |
_context | Object |
Returns
Promise
<string
>
Inherited from
ObjectSerializer.serializeAttributeKey
Defined in
src/object/objectSerializer.ts:98
serializeAttributeValue
▸ Protected
serializeAttributeValue(_instance
, def
, rawValue
, _context
): Promise
<unknown
>
Parameters
Name | Type |
---|---|
_instance | ModelInstance |
def | ModelAttribute |
rawValue | unknown |
_context | Object |
Returns
Promise
<unknown
>
Inherited from
ObjectSerializer.serializeAttributeValue
Defined in
src/object/objectSerializer.ts:143
serializeId
▸ Protected
serializeId(id?
): undefined
| string
Serialize an instance's ID.
Parameters
Name | Type |
---|---|
id? | Optional <ModelIdType > |
Returns
undefined
| string
Defined in
src/jsonapi/jsonApiSerializer.ts:78
serializeInstanceIdentifier
▸ Protected
serializeInstanceIdentifier(instance
): Object
Serialize an instance unique identifier object.
Parameters
Name | Type |
---|---|
instance | ModelInstance |
Returns
Object
Name | Type |
---|---|
id | undefined | string |
lid | undefined | string |
type | string |
Defined in
src/jsonapi/jsonApiSerializer.ts:65
serializeRelatedInstance
▸ Protected
serializeRelatedInstance(_instance
, _def
, related
): Promise
<{ id
: undefined
| string
; lid
: undefined
| string
; type
: string
= instance.$model.$type }>
Parameters
Name | Type |
---|---|
_instance | ModelInstance |
_def | ModelRelation |
related | ModelInstance |
Returns
Promise
<{ id
: undefined
| string
; lid
: undefined
| string
; type
: string
= instance.$model.$type }>
Inherit Doc
Overrides
ObjectSerializer.serializeRelatedInstance
Defined in
src/jsonapi/jsonApiSerializer.ts:52
serializeRelationKey
▸ Protected
serializeRelationKey(instance
, def
, _context
): Promise
<string
>
Parameters
Name | Type |
---|---|
instance | ModelInstance |
def | ModelRelation |
_context | Object |
Returns
Promise
<string
>
Inherited from
ObjectSerializer.serializeRelationKey
Defined in
src/object/objectSerializer.ts:106
serializeRelationValue
▸ Protected
serializeRelationValue(instance
, def
, rawValue
, context
): Promise
<unknown
>
Parameters
Name | Type |
---|---|
instance | ModelInstance |
def | ModelRelation |
rawValue | unknown |
context | Object |
Returns
Promise
<unknown
>
Inherited from
ObjectSerializer.serializeRelationValue
Defined in
src/object/objectSerializer.ts:154
shouldSerializeAttribute
▸ Protected
shouldSerializeAttribute(instance
, def
, rawValue
, context
): Promise
<boolean
>
Parameters
Name | Type |
---|---|
instance | ModelInstance |
def | ModelAttribute |
rawValue | unknown |
context | Object |
Returns
Promise
<boolean
>
Inherited from
ObjectSerializer.shouldSerializeAttribute
Defined in
src/object/objectSerializer.ts:114
shouldSerializeProp
▸ Protected
shouldSerializeProp(instance
, def
, rawValue
, _context
): Promise
<boolean
>
Parameters
Name | Type |
---|---|
instance | ModelInstance |
def | ModelRelation | ModelAttribute |
rawValue | unknown |
_context | Object |
Returns
Promise
<boolean
>
Inherited from
ObjectSerializer.shouldSerializeProp
Defined in
src/object/objectSerializer.ts:132
shouldSerializeRelation
▸ Protected
shouldSerializeRelation(instance
, def
, rawValue
, context
): Promise
<boolean
>
Parameters
Name | Type |
---|---|
instance | ModelInstance |
def | ModelRelation |
rawValue | unknown |
context | Object |
Returns
Promise
<boolean
>
Inherited from
ObjectSerializer.shouldSerializeRelation
Defined in
src/object/objectSerializer.ts:123