MCPcopy Index your code
hub / github.com/tidwall/gjson / ValidBytes

Function ValidBytes

gjson.go:2762–2765  ·  view source on GitHub ↗

ValidBytes returns true if the input is valid json. if !gjson.Valid(json) { return errors.New("invalid json") } value := gjson.Get(json, "name.last") If working with bytes, this method preferred over ValidBytes(string(data))

(json []byte)

Source from the content-addressed store, hash-verified

2760//
2761// If working with bytes, this method preferred over ValidBytes(string(data))
2762func ValidBytes(json []byte) bool {
2763 _, ok := validpayload(json, 0)
2764 return ok
2765}
2766
2767func parseUint(s string) (n uint64, ok bool) {
2768 var i int

Callers 1

BenchmarkValidBytesFunction · 0.85

Calls 1

validpayloadFunction · 0.85

Tested by 1

BenchmarkValidBytesFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…