MCPcopy Create free account
hub / github.com/chain/txvm / ValueType

Function ValueType

encoding/json/value.go:18–43  ·  view source on GitHub ↗
(data []byte)

Source from the content-addressed store, hash-verified

16)
17
18func ValueType(data []byte) (Value, error) {
19 var first byte
20 for _, c := range data {
21 if !isSpace(c) {
22 first = c
23 break
24 }
25 }
26 switch first {
27 case 'n':
28 return Null, nil
29 case 't':
30 return True, nil
31 case 'f':
32 return False, nil
33 case '[':
34 return Array, nil
35 case '{':
36 return Object, nil
37 case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
38 return Number, nil
39 case '"':
40 return String, nil
41 }
42 return Unknown, errors.New("unknown json value type")
43}
44
45// taken from std encoding/json
46func isSpace(c byte) bool {

Callers 1

UnmarshalJSONMethod · 0.85

Calls 1

isSpaceFunction · 0.70

Tested by

no test coverage detected