Closed FeliciousX closed 4 years ago
@FeliciousX @stilio @kartikluke
Hi! Is the problem still relevant?
And do you have any ideas how should look deserialized output with root meta and links, when there is collection or one item in data?
Like this?
type TDeserialized = {
stuff: TJsonaModel | TJsonaModel[] | null,
meta: TAnyKeyValueObject,
links: TLinks,
};
The problem is still relevant @olosegres. I'm looking forward to migrate from previously used jsonapi deserializer library because it doesn't support circular relationships properly and maintainer seems to be very busy 🙂
I believe you should do it like that:
type TDeserialized = {
data: TJsonaModel | TJsonaModel[] | null, // "stuff" isn't very descriptive
meta: TAnyKeyValueObject,
links: TLinks,
};
@konovalov-nk I use "stuff" to show that it is not "data" from json, in the code they are found nearby
@konovalov-nk Such an update creates a number of inconveniences, the main of which is the difficulty of updating to new versions for those already using jsona.
Why you can't extend Jsona class in your code or just wrap jsona.deserialize
in function, that will add links and meta to output?
Yup that's exactly what we are doing now but we also would like to deeply camelize all keys (even nested ones) we're receiving from the back-end. Otherwise, we have to use some kind of pre-processing, like transformResponse
from the axios
. It works, but workaround seems to be a little hacky.
This could be an option and surely doesn't have to be a default behaviour. It's more about the vision for the jsona
. Do you feel like it should stick to the JSON:API standard and implement specifications exactly like visioned? Or rather implement things a bit different using your/community perspective?
Jsona is a tool to simplify the work with standardized data. Everything inside the meta is not standardized and jsona cannot take into account all the special cases. Thus, everything that is not standardized will look a bit hacky, I think this is normal.
But if you see a way to make jsona better, then welcome, we can consider your PRs :)
the default
simplePropertyMappers
does not work with pagination whenbody
containslink
example..
when deserialized, will be
I see that
setLinks
exists on thesimplePropertyMapper
herebut it seems that only
links
insidedata
will be checked, but not thebody.links
( which is wherelinks
will exist if it's for pagination )