Documentation
¶
Overview ¶
Package jsonx reads and writes JSON as Python's json module does, which the files training and evaluation tools read are written in: an object keeps the order of its keys, a number the text it was written with, and a value is laid out as json.dumps lays it out, with a space after each comma and colon and the text of strings left as it is
Index ¶
- func Decode(data []byte) (any, error)
- func Encode(v any) ([]byte, error)
- func Float(v any) (float64, bool)
- func Indent(v any, ascii bool) ([]byte, error)
- func Int(v any) (int64, bool)
- func Text(v any) string
- func Truthy(v any) bool
- type Object
- func (o *Object) Clone() *Object
- func (o *Object) Delete(key string)
- func (o *Object) Get(key string) (any, bool)
- func (o *Object) Keys() []string
- func (o *Object) Len() int
- func (o *Object) MarshalJSON() ([]byte, error)
- func (o *Object) Set(key string, value any)
- func (o *Object) Value(key string) any
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decode ¶
Value of the JSON text: an *Object, a []any, a string, a json.Number, a bool or nil, objects keeping the order of their keys
func Encode ¶
One line of JSON as json.dumps writes it with ensure_ascii off: a space after each comma and colon, text left as it is
func Indent ¶
JSON as json.dump writes it with an indent of two: each item on its own line, every character past ASCII escaped when ascii is set
Types ¶
type Object ¶
type Object struct {
// contains filtered or unexported fields
}
Object of JSON whose keys keep the order they were set in, the first setting of a key giving its place
func (*Object) MarshalJSON ¶
The object as one line of JSON in its order, for code that writes it through encoding/json