mirror of
https://github.com/kubescape/kubescape.git
synced 2026-04-15 06:58:11 +00:00
* feat: added support for ListControls and GetFrameworks * perf: introduced jsoniter unmarshalling for faster decoding * introduced stricted error handling & predefined errors: * suppressed edge cases when a flaky value is returned instead of an error * added full unit tests of LoadPolicy Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
27 lines
547 B
Go
27 lines
547 B
Go
package getter
|
|
|
|
import (
|
|
"strings"
|
|
|
|
stdjson "encoding/json"
|
|
|
|
jsoniter "github.com/json-iterator/go"
|
|
)
|
|
|
|
var (
|
|
json jsoniter.API
|
|
)
|
|
|
|
func init() {
|
|
// NOTE(fredbi): attention, this configuration rounds floats down to 6 digits
|
|
// For finer-grained config, see: https://pkg.go.dev/github.com/json-iterator/go#section-readme
|
|
json = jsoniter.ConfigFastest
|
|
}
|
|
|
|
// JSONDecoder returns JSON decoder for given string
|
|
func JSONDecoder(origin string) *stdjson.Decoder {
|
|
dec := stdjson.NewDecoder(strings.NewReader(origin))
|
|
dec.UseNumber()
|
|
return dec
|
|
}
|