4 ms·
> What is the best way to map objects to/from JSON? - What is the best way to map objects to/from a database? If you are doing heavy sql queries, then it might
by agnivade 9y ago
> What is the best way to map objects to/from JSON? - What is the best way to map objects to/from a database?
If you are doing heavy sql queries, then it might be beneficial for you to use an ORM. There are plently of those out there, so choose one you like. Just create structs for your tables and run your queries.
If you are doing light/moderate sql. Just have an interface for your db calls, wrap your responses in a struct and use json tags for json encoding/decoding.
> What is the best way to prevent a request from crashing the server and killing a bunch of unrelated requests?
I use negroni. And its recovery middleware does exactly that.