You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now after deserialization, we don't have access to the meta data like meta, links and so on, only to the data itself.
This has a caveat, that if we pass or return that data to another method, we lose access to that meta data and forces us now to destructure it before deserialization to pass it as an extra param.
This could be easily solved if that meta data is returned as a non enumerable, non writable, non configurable property keyed with a Symbol, to avoid clashes, so we can have access to it at any time if we have a reference to the deserialized data itself.
For instance:
let deserializedData: any = new JsonApiSerializer
.Deserializer(JSON_DESERIALIZER_DEFAULT_OPTIONS)
.deserialize(jsonApiResponse);
console.log(deserializedData[JsonApiSerializer.EXTRAS_SYMBOL]);
// Example output could be:
{
extras: {
links: {...},
meta: {...}
}
}
// Extras Symbol could be something like:
JsonApiSerializer.EXTRAS_SYMBOL = new Symbol('json-api-serializer-extras-symbol');
The text was updated successfully, but these errors were encountered:
Right now after deserialization, we don't have access to the meta data like
meta
,links
and so on, only to the data itself.This has a caveat, that if we pass or return that data to another method, we lose access to that meta data and forces us now to destructure it before deserialization to pass it as an extra param.
This could be easily solved if that meta data is returned as a non enumerable, non writable, non configurable property keyed with a Symbol, to avoid clashes, so we can have access to it at any time if we have a reference to the deserialized data itself.
For instance:
The text was updated successfully, but these errors were encountered: