How to convert a complex json response?
I use vue-query to get a very complex json from an endpoint. The {data} received is an array of complicated objects containing other objects and array of objects.
The data is a reactive object. I need to transform this complicated object into completely different format so that I can show it in a tree format. This tree format data also needs to be reactive.
Do I need to convert my reactive response to a plain JSON, do my transformation and then convert it back into a reactive format? What's the best strategy to do this?
4 Replies
other-emerald•3y ago
Hi. You can use
select: (data)=>...
option to transform your responsemultiple-amethystOP•3y ago
Can you be a bit more specific, where is
select:
, is it a vue-query thing?other-emerald•3y ago
Here is example
https://tanstack.com/query/v4/docs/guides/migrating-to-react-query-3#query-data-selectors
Migrating to React Query 3 | TanStack Query Docs
Previous versions of React Query were awesome and brought some amazing new features, more magic, and an overall better experience to the library. They also brought on massive adoption and likewise a lot of refining fire (issues/contributions) to the library and brought to light a few things that needed more polish to make the library even bette...
multiple-amethystOP•3y ago
Thanks, Max. Much appreciated
Worked like a charm