Datasource: Use json-iterator configuration compatible with standard library (#30732) (#30739)

This will make sure that any map keys in JSON is ordered in /api/ds/query response.

(cherry picked from commit f62eb28f3e)

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
This commit is contained in:
Grot (@grafanabot)
2021-01-29 16:17:03 +01:00
committed by GitHub
co-authored by Marcus Efraimsson
parent 1e8019aff5
commit 021ef24ea9
2 changed files with 11 additions and 2 deletions
+6 -1
View File
@@ -102,7 +102,12 @@ func (r StreamingResponse) WriteTo(ctx *models.ReqContext) {
header[k] = v
}
ctx.Resp.WriteHeader(r.status)
enc := jsoniter.NewEncoder(ctx.Resp)
// Use a configuration that's compatible with the standard library
// to minimize the risk of introducing bugs. This will make sure
// that map keys is ordered.
jsonCfg := jsoniter.ConfigCompatibleWithStandardLibrary
enc := jsonCfg.NewEncoder(ctx.Resp)
if err := enc.Encode(r.body); err != nil {
ctx.Logger.Error("Error writing to response", "err", err)
}