forked from grafana/grafana-plugin-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
query_result_meta.go
28 lines (23 loc) · 877 Bytes
/
query_result_meta.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package data
import "encoding/json"
// QueryResultMeta matches:
// https://github.com/grafana/grafana/blob/master/packages/grafana-data/src/types/data.ts#L11
// NOTE -- in javascript this can accept any `[key: string]: any;` however
// this interface only exposes the values we want to be exposed
type QueryResultMeta struct {
// Used in Explore for highlighting
SearchWords []string `json:"searchWords,omitempty"`
// Used in Explore to show limit applied to search result
Limit int64 `json:"limit,omitempty"`
// Datasource specific values
Custom map[string]interface{} `json:"custom,omitempty"`
}
// QueryResultMetaFromJSON creates a QueryResultMeta from a json string
func QueryResultMetaFromJSON(jsonStr string) (*QueryResultMeta, error) {
var m QueryResultMeta
err := json.Unmarshal([]byte(jsonStr), &m)
if err != nil {
return nil, err
}
return &m, nil
}