Documentation
¶
Index ¶
- type ArrayBuilderStruct
- func (arrayBuilder *ArrayBuilderStruct) AddBool(value bool)
- func (arrayBuilder *ArrayBuilderStruct) AddInt(value int)
- func (arrayBuilder *ArrayBuilderStruct) AddInt32(key string, value int32)
- func (arrayBuilder *ArrayBuilderStruct) AddInt64(value int64)
- func (arrayBuilder *ArrayBuilderStruct) AddJSON(value string)
- func (arrayBuilder *ArrayBuilderStruct) AddNull()
- func (arrayBuilder *ArrayBuilderStruct) AddString(value string)
- func (arrayBuilder *ArrayBuilderStruct) Done() string
- type ArrayStruct
- func (array *ArrayStruct) AddBool(value bool)
- func (array *ArrayStruct) AddInt(value int)
- func (array *ArrayStruct) AddInt32(value int32)
- func (array *ArrayStruct) AddInt64(value int64)
- func (array *ArrayStruct) AddJSONArray(value ArrayStruct)
- func (array *ArrayStruct) AddJSONObject(value ObjectStruct)
- func (array *ArrayStruct) AddNull()
- func (array *ArrayStruct) AddNumber(value string)
- func (array *ArrayStruct) AddString(value string)
- func (array *ArrayStruct) ExistsAndIsNull(index int) bool
- func (array *ArrayStruct) GetBool(index int) (bool, error)
- func (array *ArrayStruct) GetInt(key int) (int, error)
- func (array *ArrayStruct) GetInt32(key int) (int32, error)
- func (array *ArrayStruct) GetInt64(key int) (int64, error)
- func (array *ArrayStruct) GetJSONArray(index int) (ArrayStruct, error)
- func (array *ArrayStruct) GetJSONObject(index int) (ObjectStruct, error)
- func (array *ArrayStruct) GetNumber(key int) (string, error)
- func (array *ArrayStruct) GetString(index int) (string, error)
- func (array *ArrayStruct) IsNull(index int) (bool, error)
- func (array *ArrayStruct) Length() int
- func (array *ArrayStruct) SetBool(index int, value bool)
- func (array *ArrayStruct) SetInt(index int, value int)
- func (array *ArrayStruct) SetInt32(index int, value int32)
- func (array *ArrayStruct) SetInt64(index int, value int64)
- func (array *ArrayStruct) SetJSONArray(index int, value ArrayStruct)
- func (array *ArrayStruct) SetJSONObject(index int, value ObjectStruct)
- func (array *ArrayStruct) SetNull(index int)
- func (array *ArrayStruct) SetNumber(index int, value string)
- func (array *ArrayStruct) SetString(index int, value string)
- func (array *ArrayStruct) String() string
- type ObjectBuilderStruct
- func (objectBuilder *ObjectBuilderStruct) AddBool(name string, value bool)
- func (objectBuilder *ObjectBuilderStruct) AddInt(name string, value int)
- func (objectBuilder *ObjectBuilderStruct) AddInt32(name string, value int32)
- func (objectBuilder *ObjectBuilderStruct) AddInt64(name string, value int64)
- func (objectBuilder *ObjectBuilderStruct) AddJSON(name string, value string)
- func (objectBuilder *ObjectBuilderStruct) AddNull(name string)
- func (objectBuilder *ObjectBuilderStruct) AddString(name string, value string)
- func (objectBuilder *ObjectBuilderStruct) Done() string
- type ObjectStruct
- func (object *ObjectStruct) ExistsAndIsNull(key string) bool
- func (object *ObjectStruct) GetBool(key string) (bool, error)
- func (object *ObjectStruct) GetInt(key string) (int, error)
- func (object *ObjectStruct) GetInt32(key string) (int32, error)
- func (object *ObjectStruct) GetInt64(key string) (int64, error)
- func (object *ObjectStruct) GetJSONArray(key string) (ArrayStruct, error)
- func (object *ObjectStruct) GetJSONObject(key string) (ObjectStruct, error)
- func (object *ObjectStruct) GetNumber(key string) (string, error)
- func (object *ObjectStruct) GetString(key string) (string, error)
- func (object *ObjectStruct) Has(key string) bool
- func (object *ObjectStruct) IsNull(key string) (bool, error)
- func (object *ObjectStruct) SetBool(key string, value bool)
- func (object *ObjectStruct) SetInt(key string, value int)
- func (object *ObjectStruct) SetInt32(key string, value int32)
- func (object *ObjectStruct) SetInt64(key string, value int64)
- func (object *ObjectStruct) SetJSONArray(key string, value ArrayStruct)
- func (object *ObjectStruct) SetJSONObject(key string, value ObjectStruct)
- func (object *ObjectStruct) SetNull(key string)
- func (object *ObjectStruct) SetNumber(key string, value string)
- func (object *ObjectStruct) SetString(key string, value string)
- func (object *ObjectStruct) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArrayBuilderStruct ¶
type ArrayBuilderStruct struct {
// contains filtered or unexported fields
}
Use NewArrayBuilder().
func NewArrayBuilder ¶
func NewArrayBuilder() *ArrayBuilderStruct
func (*ArrayBuilderStruct) AddBool ¶
func (arrayBuilder *ArrayBuilderStruct) AddBool(value bool)
Encodes the value to a JSON boolean and adds it as a new array element.
func (*ArrayBuilderStruct) AddInt ¶
func (arrayBuilder *ArrayBuilderStruct) AddInt(value int)
Encodes the value to a JSON number and adds it as a new array element.
func (*ArrayBuilderStruct) AddInt32 ¶
func (arrayBuilder *ArrayBuilderStruct) AddInt32(key string, value int32)
Encodes the value to a JSON number and adds it as a new array element.
func (*ArrayBuilderStruct) AddInt64 ¶
func (arrayBuilder *ArrayBuilderStruct) AddInt64(value int64)
Encodes the value to a JSON number and adds it as a new array element.
func (*ArrayBuilderStruct) AddJSON ¶
func (arrayBuilder *ArrayBuilderStruct) AddJSON(value string)
Adds the JSON value as a new array element. The value is assumed to be valid JSON.
func (*ArrayBuilderStruct) AddNull ¶
func (arrayBuilder *ArrayBuilderStruct) AddNull()
Adds null to the array.
func (*ArrayBuilderStruct) AddString ¶
func (arrayBuilder *ArrayBuilderStruct) AddString(value string)
Encodes the value to a JSON string and adds it as a new array element. Control characters not allowed in JSON strings are ignored when encoding.
func (*ArrayBuilderStruct) Done ¶
func (arrayBuilder *ArrayBuilderStruct) Done() string
Returns the built JSON. The builder can no longer be used.
type ArrayStruct ¶
type ArrayStruct struct {
// contains filtered or unexported fields
}
Represents a JSON array. The zero value is a ready-to-use empty array.
func ParseArray ¶
func ParseArray(s string) (ArrayStruct, error)
Parses a JSON array. Ignores any leading and trailing whitespace. Returns an error if the string is an invalid JSON array or an object has duplicate member names.
JSON object member names are compared after resolving any escaped characters.
func (*ArrayStruct) AddBool ¶
func (array *ArrayStruct) AddBool(value bool)
Appends a JSON boolean value at the end of the array.
func (*ArrayStruct) AddInt ¶
func (array *ArrayStruct) AddInt(value int)
Appends a JSON number value at the end of the array.
func (*ArrayStruct) AddInt32 ¶
func (array *ArrayStruct) AddInt32(value int32)
Appends a JSON number value at the end of the array.
func (*ArrayStruct) AddInt64 ¶
func (array *ArrayStruct) AddInt64(value int64)
Appends a JSON number value at the end of the array.
func (*ArrayStruct) AddJSONArray ¶
func (array *ArrayStruct) AddJSONArray(value ArrayStruct)
Appends a JSON array value at the end of the array.
func (*ArrayStruct) AddJSONObject ¶
func (array *ArrayStruct) AddJSONObject(value ObjectStruct)
Appends a JSON object value at the end of the array.
func (*ArrayStruct) AddNull ¶
func (array *ArrayStruct) AddNull()
Appends a JSON null value at the end of the array.
func (*ArrayStruct) AddNumber ¶
func (array *ArrayStruct) AddNumber(value string)
Appends a JSON number value at the end of the array.
func (*ArrayStruct) AddString ¶
func (array *ArrayStruct) AddString(value string)
Appends a JSON string value at the end of the array.
func (*ArrayStruct) ExistsAndIsNull ¶
func (array *ArrayStruct) ExistsAndIsNull(index int) bool
Returns true if the value at the index is null.
func (*ArrayStruct) GetBool ¶
func (array *ArrayStruct) GetBool(index int) (bool, error)
Returns an error if an item doesn't exist in the index or the value isn't a JSON boolean.
func (*ArrayStruct) GetInt ¶
func (array *ArrayStruct) GetInt(key int) (int, error)
Returns an error if an item doesn't exist in the index, the value isn't a JSON number, or the JSON number cannot be represented as an int.
func (*ArrayStruct) GetInt32 ¶
func (array *ArrayStruct) GetInt32(key int) (int32, error)
Returns an error if an item doesn't exist in the index, the value isn't a JSON number, or the JSON number cannot be represented as an int32.
func (*ArrayStruct) GetInt64 ¶
func (array *ArrayStruct) GetInt64(key int) (int64, error)
Returns an error if an item doesn't exist in the index, the value isn't a JSON number, or the JSON number cannot be represented as an int64.
func (*ArrayStruct) GetJSONArray ¶
func (array *ArrayStruct) GetJSONArray(index int) (ArrayStruct, error)
Returns an error if an item doesn't exist in the index or the value isn't a JSON array.
func (*ArrayStruct) GetJSONObject ¶
func (array *ArrayStruct) GetJSONObject(index int) (ObjectStruct, error)
Returns an error if an item doesn't exist in the index or the value isn't a JSON object.
func (*ArrayStruct) GetNumber ¶
func (array *ArrayStruct) GetNumber(key int) (string, error)
Returns an error if an item doesn't exist in the index or the value isn't a JSON number.
func (*ArrayStruct) GetString ¶
func (array *ArrayStruct) GetString(index int) (string, error)
Returns an error if an item doesn't exist in the index or the value isn't a JSON string.
func (*ArrayStruct) IsNull ¶
func (array *ArrayStruct) IsNull(index int) (bool, error)
Returns an error if an item doesn't exist in the index.
func (*ArrayStruct) Length ¶
func (array *ArrayStruct) Length() int
func (*ArrayStruct) SetBool ¶
func (array *ArrayStruct) SetBool(index int, value bool)
Sets a JSON boolean value at index. Panics if the index is out of bounds.
func (*ArrayStruct) SetInt ¶
func (array *ArrayStruct) SetInt(index int, value int)
Sets a JSON number value at index. Panics if the index is out of bounds.
func (*ArrayStruct) SetInt32 ¶
func (array *ArrayStruct) SetInt32(index int, value int32)
Sets a JSON number value at index. Panics if the index is out of bounds.
func (*ArrayStruct) SetInt64 ¶
func (array *ArrayStruct) SetInt64(index int, value int64)
Sets a JSON number value at index. Panics if the index is out of bounds.
func (*ArrayStruct) SetJSONArray ¶
func (array *ArrayStruct) SetJSONArray(index int, value ArrayStruct)
Sets a JSON array value at index. Panics if the index is out of bounds.
func (*ArrayStruct) SetJSONObject ¶
func (array *ArrayStruct) SetJSONObject(index int, value ObjectStruct)
Sets a JSON object value at index. Panics if the index is out of bounds.
func (*ArrayStruct) SetNull ¶
func (array *ArrayStruct) SetNull(index int)
Sets a JSON null value at index. Panics if the index is out of bounds.
func (*ArrayStruct) SetNumber ¶
func (array *ArrayStruct) SetNumber(index int, value string)
Sets a JSON number value at index. Panics if the index is out of bounds.
func (*ArrayStruct) SetString ¶
func (array *ArrayStruct) SetString(index int, value string)
Sets a JSON string value at index. Panics if the index is out of bounds.
func (*ArrayStruct) String ¶
func (array *ArrayStruct) String() string
Encodes the array using ArrayBuilderStruct. Embedded objects are encoded with ObjectStruct.String(). Embedded arrays are encoded with ArrayStruct.String().
type ObjectBuilderStruct ¶
type ObjectBuilderStruct struct {
// contains filtered or unexported fields
}
Use NewObjectBuilder().
func NewObjectBuilder ¶
func NewObjectBuilder() *ObjectBuilderStruct
func (*ObjectBuilderStruct) AddBool ¶
func (objectBuilder *ObjectBuilderStruct) AddBool(name string, value bool)
Encodes the name to a JSON string and value to a JSON boolean, and adds a new object member. Succeeds even if a member with the same name already exists.
Control characters not allowed in JSON strings are ignored when encoding values to JSON strings.
func (*ObjectBuilderStruct) AddInt ¶
func (objectBuilder *ObjectBuilderStruct) AddInt(name string, value int)
Encodes the name to a JSON string and value to a JSON number, and adds a new object member. Succeeds even if a member with the same name already exists.
Control characters not allowed in JSON strings are ignored when encoding values to JSON strings.
func (*ObjectBuilderStruct) AddInt32 ¶
func (objectBuilder *ObjectBuilderStruct) AddInt32(name string, value int32)
Encodes the name to a JSON string and value to a JSON number, and adds a new object member. Succeeds even if a member with the same name already exists.
Control characters not allowed in JSON strings are ignored when encoding values to JSON strings.
func (*ObjectBuilderStruct) AddInt64 ¶
func (objectBuilder *ObjectBuilderStruct) AddInt64(name string, value int64)
Encodes the name to a JSON string and value to a JSON number, and adds a new object member. Succeeds even if a member with the same name already exists.
Control characters not allowed in JSON strings are ignored when encoding values to JSON strings.
func (*ObjectBuilderStruct) AddJSON ¶
func (objectBuilder *ObjectBuilderStruct) AddJSON(name string, value string)
Encodes the name to a JSON string and adds a new object member with the value untouched. The value is assumed to be valid JSON. Succeeds even if a member with the same name already exists.
Control characters not allowed in JSON strings are ignored when encoding values to JSON strings.
func (*ObjectBuilderStruct) AddNull ¶
func (objectBuilder *ObjectBuilderStruct) AddNull(name string)
Encodes the name to a JSON string and adds a new object member with a null value. Succeeds even if a member with the same name already exists.
Control characters not allowed in JSON strings are ignored when encoding values to JSON strings.
func (*ObjectBuilderStruct) AddString ¶
func (objectBuilder *ObjectBuilderStruct) AddString(name string, value string)
Encodes the name and value to JSON strings, and adds a new object member. Succeeds even if a member with the same name already exists.
Control characters not allowed in JSON strings are ignored when encoding values to JSON strings.
func (*ObjectBuilderStruct) Done ¶
func (objectBuilder *ObjectBuilderStruct) Done() string
Returns the built JSON. The builder can no longer be used.
type ObjectStruct ¶
type ObjectStruct struct {
// contains filtered or unexported fields
}
Represents a JSON object. The zero value is a ready-to-use empty object.
func ParseObject ¶
func ParseObject(s string) (ObjectStruct, error)
Parses a JSON object. Ignores any leading and trailing whitespace. Returns an error if the string is an invalid JSON object or an object has duplicate member names.
JSON object member names are compared after resolving any escaped characters.
func (*ObjectStruct) ExistsAndIsNull ¶
func (object *ObjectStruct) ExistsAndIsNull(key string) bool
Returns true if the key exists and the value is null.
func (*ObjectStruct) GetBool ¶
func (object *ObjectStruct) GetBool(key string) (bool, error)
Returns an error if the key doesn't exist or the value isn't a JSON boolean.
func (*ObjectStruct) GetInt ¶
func (object *ObjectStruct) GetInt(key string) (int, error)
Returns an error if the key doesn't exist, the value isn't a JSON number, or the JSON number cannot be represented as an int.
func (*ObjectStruct) GetInt32 ¶
func (object *ObjectStruct) GetInt32(key string) (int32, error)
Returns an error if the key doesn't exist, the value isn't a JSON number, or the JSON number cannot be represented as an int32.
func (*ObjectStruct) GetInt64 ¶
func (object *ObjectStruct) GetInt64(key string) (int64, error)
Returns an error if the key doesn't exist, the value isn't a JSON number, or the JSON number cannot be represented as an int64.
func (*ObjectStruct) GetJSONArray ¶
func (object *ObjectStruct) GetJSONArray(key string) (ArrayStruct, error)
Returns an error if the key doesn't exist or the value isn't a JSON array.
func (*ObjectStruct) GetJSONObject ¶
func (object *ObjectStruct) GetJSONObject(key string) (ObjectStruct, error)
Returns an error if the key doesn't exist or the value isn't a JSON object.
func (*ObjectStruct) GetNumber ¶
func (object *ObjectStruct) GetNumber(key string) (string, error)
Returns an error if the key doesn't exist or the value isn't a JSON number
func (*ObjectStruct) GetString ¶
func (object *ObjectStruct) GetString(key string) (string, error)
Returns an error if the key doesn't exist or the value isn't a JSON string.
func (*ObjectStruct) Has ¶
func (object *ObjectStruct) Has(key string) bool
func (*ObjectStruct) IsNull ¶
func (object *ObjectStruct) IsNull(key string) (bool, error)
Returns an error if the key doesn't exist.
func (*ObjectStruct) SetBool ¶
func (object *ObjectStruct) SetBool(key string, value bool)
Set a member with a JSON boolean value. Overrides any member with the same name.
func (*ObjectStruct) SetInt ¶
func (object *ObjectStruct) SetInt(key string, value int)
Set a member with a JSON number value. Overrides any member with the same name.
func (*ObjectStruct) SetInt32 ¶
func (object *ObjectStruct) SetInt32(key string, value int32)
Set a member with a JSON number value. Overrides any member with the same name.
func (*ObjectStruct) SetInt64 ¶
func (object *ObjectStruct) SetInt64(key string, value int64)
Set a member with a JSON number value. Overrides any member with the same name.
func (*ObjectStruct) SetJSONArray ¶
func (object *ObjectStruct) SetJSONArray(key string, value ArrayStruct)
Set a member with a JSON array value. Overrides any member with the same name.
func (*ObjectStruct) SetJSONObject ¶
func (object *ObjectStruct) SetJSONObject(key string, value ObjectStruct)
Set a member with a JSON object value. Overrides any member with the same name.
func (*ObjectStruct) SetNull ¶
func (object *ObjectStruct) SetNull(key string)
Set a member with a JSON null value. Overrides any member with the same name.
func (*ObjectStruct) SetNumber ¶
func (object *ObjectStruct) SetNumber(key string, value string)
Set a member with a JSON number value. Overrides any member with the same name.
func (*ObjectStruct) SetString ¶
func (object *ObjectStruct) SetString(key string, value string)
Set a member with a JSON string value. Overrides any member with the same name.
func (*ObjectStruct) String ¶
func (object *ObjectStruct) String() string
Encodes the object using ObjectBuilderStruct. Embedded objects are encoded with ObjectStruct.String(). Embedded arrays are encoded with ArrayStruct.String().