diff --git a/pkg/api/response/response.go b/pkg/api/response/response.go index e4ebbfc0d56..297d0051461 100644 --- a/pkg/api/response/response.go +++ b/pkg/api/response/response.go @@ -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) } diff --git a/pkg/tsdb/models.go b/pkg/tsdb/models.go index 9953619400c..6ff35fd6a5a 100644 --- a/pkg/tsdb/models.go +++ b/pkg/tsdb/models.go @@ -264,5 +264,9 @@ func (df *dataFrames) MarshalJSON() ([]byte, error) { return nil, err } - return jsoniter.Marshal(encoded) + // 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 + return jsonCfg.Marshal(encoded) }