all repos

json2go @ fc9c7df

convert json to go type annotations

json2go/value.go (view raw)

Oleksandr Smirnov Oleksandr Smirnov
olexsmir@gmail.com
refactor: use an actual parser instead of reflection..., 11 days ago
1
package json2go
2
3
// ValueType the kind of json value represented by a [Value] node.
4
type ValueType int
5
6
const (
7
	NullValue ValueType = iota
8
	BoolValue
9
	StringValue
10
	NumberValue
11
	DecimalValue
12
	ObjectValue
13
	ArrayValue
14
)
15
16
// Value represents a json value in the AST.
17
type Value struct {
18
	Kind ValueType
19
20
	// only one of these is set depending on Kind
21
	Str    string
22
	Int    int64
23
	Float  float64
24
	Bool   bool
25
	Object []Field // ordered, preserves key order
26
	Array  []Value
27
}
28
29
type Field struct {
30
	K string
31
	V Value
32
}