Closed marceloverdijk closed 6 years ago
Quick thought, maybe this could be solved with meta-aware link getters in combination with disabling null value serialisation?
In general I do like null properties to be serialized, especially for the ”attributes”
element of the resources.
But for the core jsonapi elements I don’t think it’s usefull, like the ”meta”
element.
And that’s also why I would prefer the shorthand version of the link if possible.
PS: I know I’m not consistent regarding serializing null values here 😇 (but at least it’s how I would prefer the output to look like)
I also don’t know how your quick thought would work because conditionally you wat the omit the href
(shorthand variant) or not (in case meta is not null).
Closed as fixed by PR #188
Currently links are rendered as:
and without meta as:
or in case https://github.com/jasminb/jsonapi-converter/pull/181 is accepted as:
Still not perfect. In case no meta is available I think rendering it to the below sample would be preferable:
This is also done like this in the jsonapi specs.
We could solve this by writing a custom
JsonSerializer
for theLink
object.Would you be interested in a PR for that?