Skip to content

Flatted vs JSON #270

Answered by Vadorequest
samuelcastro asked this question in Q&A
Jan 19, 2021 · 1 comments · 6 replies
Discussion options

You must be logged in to vote

I wonder the need to add another lib just to serialize the data considering that Customer (at least not on NRN) does not have a circular dependence.

Honestly, it should be a default. If you return dynamic data from getServerSideProps or similar, and if those data contain circular reference, you'll break your whole page for your customers.

Serializing the data using a safe serializer (e.g: Flatted) has several advantages:

  • Ensures it won't break because of dynamic data containing circular references
  • Doesn't increase build size because executed on the server only
  • Allows using circular references, which can be great when using nested entities (such as DB data models sent to the client)

I'…

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@Vadorequest
Comment options

@Vadorequest
Comment options

@samuelcastro
Comment options

@samuelcastro
Comment options

@Vadorequest
Comment options

Answer selected by Vadorequest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants