From 81e3f93677203af5f14642dcf6ee923ae0bf78af Mon Sep 17 00:00:00 2001 From: Kyle Brandt Date: Tue, 26 May 2020 14:32:00 -0400 Subject: [PATCH] Backend Readme: Add section on avoiding simplejson (#25116) --- pkg/README.md | 4 ++++ pkg/components/simplejson/simplejson.go | 2 ++ 2 files changed, 6 insertions(+) diff --git a/pkg/README.md b/pkg/README.md index f4db0b0f211..87a2c21625f 100644 --- a/pkg/README.md +++ b/pkg/README.md @@ -71,6 +71,10 @@ Refactor HTTP handlers so that the handler methods are on the HttpServer instanc Store newly introduced date columns in the database as epochs if they require date comparison. This permits a unified approach for comparing dates against all the supported databases instead of handling dates differently for each database. Also, by comparing epochs, we no longer need error pruning transformations to and from other time zones. +### Avoid use of the simplejson package + +Use of the `simplejson` package (`pkg/components/simplejson`) in place of types (Go structs) results in code that is difficult to maintain. Instead, create types for objects and use the Go standard library's [`encoding/json`](https://golang.org/pkg/encoding/json/) package. + ### Provisionable* All new features that require state should be possible to configure using config files. For example: diff --git a/pkg/components/simplejson/simplejson.go b/pkg/components/simplejson/simplejson.go index 35e305eb414..4e2a4f36d6c 100644 --- a/pkg/components/simplejson/simplejson.go +++ b/pkg/components/simplejson/simplejson.go @@ -1,3 +1,5 @@ +// Package simplejson provides a wrapper for arbitrary JSON objects that adds methods to access properties. +// Use of this package in place of types and the standard library's encoding/json package is strongly discouraged. package simplejson import (