Commit 4e37941c by Arve Knudsen Committed by GitHub

Backend style guide: Document JSON guidelines (#30267)

* Backend style guide: Document JSON guidelines

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
parent 6ce5740e
...@@ -89,3 +89,12 @@ for context. ...@@ -89,3 +89,12 @@ for context.
### Unique columns ### Unique columns
If a column, or column combination, should be unique, add a corresponding uniqueness constraint through a migration. If a column, or column combination, should be unique, add a corresponding uniqueness constraint through a migration.
## JSON
The simplejson package is used a lot throughout the backend codebase, but it's legacy, so if at all possible
avoid using it in new code. Use [json-iterator](https://github.com/json-iterator/go) instead, which is a more performant
drop-in alternative to the standard [encoding/json](https://golang.org/pkg/encoding/json/) package. While encoding/json
is a fine choice, profiling shows that json-iterator may be 3-4 times more efficient for encoding. We haven't profiled
its parsing performance yet, but according to json-iterator's own benchmarks, it appears even more superior in this
department.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment