mirror of
https://github.com/grafana/grafana.git
synced 2025-02-10 23:55:47 -06:00
Datasource: Use json-iterator configuration compatible with standard library (#30732)
This will make sure that any map keys in JSON is ordered in /api/ds/query response.
This commit is contained in:
parent
9407cdd51c
commit
f62eb28f3e
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user