Documentation
¶
Index ¶
- Constants
- func FindPointerFromObjectTo(object *Node, target *Node) *c.Char
- func Free(object unsafe.Pointer)
- func FreeCStr(*c.Char)
- func GetErrorPtr() *c.Char
- func Malloc(size c.SizeT) unsafe.Pointer
- func Minify(json *c.Char)
- func Version() *c.Char
- type Bool
- type Hooks
- type Node
- func CreateArray() *Node
- func CreateBool(boolean Bool) *Node
- func CreateDoubleArray(numbers *c.Double, count c.Int) *Node
- func CreateFalse() *Node
- func CreateFloatArray(numbers *c.Float, count c.Int) *Node
- func CreateIntArray(numbers *c.Int, count c.Int) *Node
- func CreateNull() *Node
- func CreateNumber(num c.Double) *Node
- func CreateObject() *Node
- func CreateRaw(raw *c.Char) *Node
- func CreateString(string *c.Char) *Node
- func CreateStringArray(strings **c.Char, count c.Int) *Node
- func CreateStringReference(string *c.Char) *Node
- func CreateTrue() *Node
- func DetachItemViaPointer(parent *Node, item *Node) *Node
- func GenerateMergePatch(from *Node, to *Node) *Node
- func GenerateMergePatchCaseSensitive(from *Node, to *Node) *Node
- func GeneratePatches(from *Node, to *Node) *Node
- func GeneratePatchesCaseSensitive(from *Node, to *Node) *Node
- func Parse(value *c.Char) *Node
- func ParseBytes(value []byte) *Node
- func ParseString(value string) *Node
- func ParseWithLength(value *c.Char, buffer_length c.SizeT) *Node
- func ParseWithLengthOpts(value *c.Char, buffer_length c.SizeT, return_parse_end **c.Char, ...) *Node
- func ParseWithOpts(value *c.Char, return_parse_end **c.Char, require_null_terminated Bool) *Node
- func (self *Node) AddArrayToObject(name *c.Char) *Node
- func (self *Node) AddBoolToObject(name *c.Char, boolean Bool) *Node
- func (self *Node) AddFalseToObject(name *c.Char) *Node
- func (self *Node) AddItemReferenceToArray(item *Node) Bool
- func (self *Node) AddItemReferenceToObject(string *c.Char, item *Node) Bool
- func (self *Node) AddItemToArray(item *Node) Bool
- func (self *Node) AddItemToObject(string *c.Char, item *Node) Bool
- func (self *Node) AddItemToObjectCS(string *c.Char, item *Node) Bool
- func (self *Node) AddNullToObject(name *c.Char) *Node
- func (self *Node) AddNumberToObject(name *c.Char, number c.Double) *Node
- func (self *Node) AddObjectToObject(name *c.Char) *Node
- func (self *Node) AddPatchToArray(operation *c.Char, path *c.Char, value *Node)
- func (self *Node) AddRawToObject(name *c.Char, raw *c.Char) *Node
- func (self *Node) AddStringToObject(name *c.Char, string *c.Char) *Node
- func (self *Node) AddTrueToObject(name *c.Char) *Node
- func (self *Node) ApplyPatches(patches *Node) c.Int
- func (self *Node) ApplyPatchesCaseSensitive(patches *Node) c.Int
- func (self *Node) ArrayItem(index c.Int) *Node
- func (self *Node) ArraySize() c.Int
- func (self *Node) Compare(b *Node, case_sensitive Bool) Bool
- func (self *Node) CreateArrayReference() *Node
- func (self *Node) CreateObjectReference() *Node
- func (self *Node) Delete()
- func (self *Node) DeleteItemFromArray(which c.Int)
- func (self *Node) DeleteItemFromObject(string *c.Char)
- func (self *Node) DeleteItemFromObjectCaseSensitive(string *c.Char)
- func (self *Node) DetachItemFromArray(which c.Int) *Node
- func (self *Node) DetachItemFromObject(string *c.Char) *Node
- func (self *Node) DetachItemFromObjectCaseSensitive(string *c.Char) *Node
- func (self *Node) Duplicate(recurse Bool) *Node
- func (self *Node) HasObjectItem(string *c.Char) Bool
- func (self *Node) InsertItemInArray(which c.Int, newitem *Node) Bool
- func (self *Node) IsArray() Bool
- func (self *Node) IsBool() Bool
- func (self *Node) IsFalse() Bool
- func (self *Node) IsInvalid() Bool
- func (self *Node) IsNull() Bool
- func (self *Node) IsNumber() Bool
- func (self *Node) IsObject() Bool
- func (self *Node) IsRaw() Bool
- func (self *Node) IsString() Bool
- func (self *Node) IsTrue() Bool
- func (self *Node) MergePatch(patch *Node) *Node
- func (self *Node) MergePatchCaseSensitive(patch *Node) *Node
- func (self *Node) NumberValue() c.Double
- func (self *Node) ObjectItem(string *c.Char) *Node
- func (self *Node) ObjectItemCaseSensitive(string *c.Char) *Node
- func (self *Node) Pointer(pointer *c.Char) *Node
- func (self *Node) PointerCaseSensitive(pointer *c.Char) *Node
- func (self *Node) Print() *c.Char
- func (self *Node) PrintBuffered(prebuffer c.Int, fmt Bool) *c.Char
- func (self *Node) PrintPreallocated(buffer *c.Char, length c.Int, format Bool) Bool
- func (self *Node) PrintUnformatted() *c.Char
- func (self *Node) ReplaceItemInArray(which c.Int, newitem *Node) Bool
- func (self *Node) ReplaceItemInObject(string *c.Char, newitem *Node) Bool
- func (self *Node) ReplaceItemInObjectCaseSensitive(string *c.Char, newitem *Node) Bool
- func (self *Node) ReplaceItemViaPointer(item *Node, replacement *Node) Bool
- func (self *Node) SetNumberHelper(number c.Double) c.Double
- func (self *Node) SetValuestring(valuestring *c.Char) *c.Char
- func (self *Node) SortObject()
- func (self *Node) SortObjectCaseSensitive()
- func (self *Node) StringValue() *c.Char
Constants ¶
const ( VERSION_MAJOR = 1 VERSION_MINOR = 7 VERSION_PATCH = 19 )
project version
const ( Invalid = 0 False = 1 True = 2 NULL = 4 Number = 8 String = 16 Array = 32 Object = 64 // raw json Raw = 128 )
cJSON Types:
const ( IsReference = 256 StringIsConst = 512 )
const CIRCULAR_LIMIT = 10000
const LLGoPackage = "link: $(pkg-config --libs libcjson_utils); -lcjson_utils -lcjson"
const NESTING_LIMIT = 1000
Variables ¶
This section is empty.
Functions ¶
func FindPointerFromObjectTo ¶ added in v0.3.3
Given a root object and a target object, construct a pointer from one to the other.
func FreeCStr ¶ added in v0.6.0
malloc/free objects using the malloc/free functions that have been set with cJSON_InitHooks
func GetErrorPtr ¶
For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds.
func Malloc ¶
malloc/free objects using the malloc/free functions that have been set with cJSON_InitHooks
Types ¶
type Hooks ¶
type Node ¶ added in v0.3.0
type Node struct {
Next *Node
Prev *Node
Child *Node
Type c.Int
Valuestring *c.Char
Valueint c.Int
Valuedouble c.Double
String *c.Char
}
The cJSON structure:
func CreateArray ¶
func CreateArray() *Node
func CreateBool ¶
func CreateFalse ¶
func CreateFalse() *Node
func CreateIntArray ¶
These utilities create an Array of count items. The parameter count cannot be greater than the number of elements in the number array, otherwise array access will be out of bounds.
func CreateNumber ¶
func CreateObject ¶
func CreateObject() *Node
func CreateStringReference ¶
Create a string where valuestring references a string so it will not be freed by cJSON_Delete
func CreateTrue ¶
func CreateTrue() *Node
func DetachItemViaPointer ¶ added in v0.3.3
Remove/Detach items from Arrays/Objects.
func GenerateMergePatch ¶ added in v0.3.3
NOTE: This modifies objects in 'from' and 'to' by sorting the elements by their key
func GenerateMergePatchCaseSensitive ¶ added in v0.3.3
func GeneratePatches ¶ added in v0.3.3
NOTE: This modifies objects in 'from' and 'to' by sorting the elements by their key
func GeneratePatchesCaseSensitive ¶ added in v0.3.3
Utility for generating patch array entries.
func ParseBytes ¶ added in v0.6.0
func ParseString ¶ added in v0.6.0
func ParseWithLength ¶
ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed.
func ParseWithLengthOpts ¶
func ParseWithOpts ¶
If you supply a ptr in return_parse_end and parsing fails, then return_parse_end will contain a pointer to the error so will match cJSON_GetErrorPtr().
func (*Node) AddArrayToObject ¶ added in v0.3.0
func (*Node) AddBoolToObject ¶ added in v0.3.0
func (*Node) AddFalseToObject ¶ added in v0.3.0
func (*Node) AddItemReferenceToArray ¶ added in v0.3.0
Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON.
func (*Node) AddItemReferenceToObject ¶ added in v0.3.0
func (*Node) AddItemToArray ¶ added in v0.3.0
Append item to the specified array/object.
func (*Node) AddItemToObject ¶ added in v0.3.0
Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object. WARNING: When this function was used, make sure to always check that (item->type & cJSON_StringIsConst) is zero before writing to `item->string`
func (*Node) AddItemToObjectCS ¶ added in v0.3.0
Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object. WARNING: When this function was used, make sure to always check that (item->type & cJSON_StringIsConst) is zero before writing to `item->string`
func (*Node) AddNullToObject ¶ added in v0.3.0
Helper functions for creating and adding items to an object at the same time. They return the added item or NULL on failure.
func (*Node) AddNumberToObject ¶ added in v0.3.0
func (*Node) AddObjectToObject ¶ added in v0.3.0
func (*Node) AddPatchToArray ¶ added in v0.3.0
Utility for generating patch array entries.
func (*Node) AddRawToObject ¶ added in v0.3.0
func (*Node) AddStringToObject ¶ added in v0.3.0
func (*Node) AddTrueToObject ¶ added in v0.3.0
func (*Node) ApplyPatches ¶ added in v0.3.0
Returns 0 for success.
func (*Node) ApplyPatchesCaseSensitive ¶ added in v0.3.0
func (*Node) ArrayItem ¶ added in v0.3.0
Retrieve item number "index" from array "array". Returns NULL if unsuccessful.
func (*Node) Compare ¶ added in v0.3.0
Recursively compare two cJSON items for equality. If either a or b is NULL or invalid, they will be considered unequal. case_sensitive determines if object keys are treated case sensitive (1) or case insensitive (0)
func (*Node) CreateArrayReference ¶ added in v0.3.0
func (*Node) CreateObjectReference ¶ added in v0.3.0
Create an object/array that only references it's elements so they will not be freed by cJSON_Delete
func (*Node) Delete ¶ added in v0.3.0
func (self *Node) Delete()
Delete a cJSON entity and all subentities.
func (*Node) DeleteItemFromArray ¶ added in v0.3.0
func (*Node) DeleteItemFromObject ¶ added in v0.3.0
func (*Node) DeleteItemFromObjectCaseSensitive ¶ added in v0.3.0
func (*Node) DetachItemFromArray ¶ added in v0.3.0
func (*Node) DetachItemFromObject ¶ added in v0.3.0
func (*Node) DetachItemFromObjectCaseSensitive ¶ added in v0.3.0
func (*Node) HasObjectItem ¶ added in v0.3.0
For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds.
func (*Node) InsertItemInArray ¶ added in v0.3.0
Update array items.
func (*Node) MergePatch ¶ added in v0.3.0
target will be modified by patch. return value is new ptr for target.
func (*Node) MergePatchCaseSensitive ¶ added in v0.3.0
generates a patch to move from -> to
func (*Node) NumberValue ¶ added in v0.3.0
func (*Node) ObjectItem ¶ added in v0.3.0
Get item "string" from object. Case insensitive.
func (*Node) ObjectItemCaseSensitive ¶ added in v0.3.0
func (*Node) Pointer ¶ added in v0.3.0
Implement RFC6901 (https://tools.ietf.org/html/rfc6901) JSON Pointer spec.
func (*Node) PointerCaseSensitive ¶ added in v0.3.0
func (*Node) PrintBuffered ¶ added in v0.3.0
Render a cJSON entity to text using a buffered strategy. prebuffer is a guess at the final size. guessing well reduces reallocation. fmt=0 gives unformatted, =1 gives formatted
func (*Node) PrintPreallocated ¶ added in v0.3.0
NOTE: cJSON is not always 100% accurate in estimating how much memory it will use, so to be safe allocate 5 bytes more than you actually need
func (*Node) PrintUnformatted ¶ added in v0.3.0
Render a cJSON entity to text for transfer/storage without any formatting.
func (*Node) ReplaceItemInArray ¶ added in v0.3.0
func (*Node) ReplaceItemInObject ¶ added in v0.3.0
func (*Node) ReplaceItemInObjectCaseSensitive ¶ added in v0.3.0
func (*Node) ReplaceItemViaPointer ¶ added in v0.3.0
func (*Node) SetNumberHelper ¶ added in v0.3.0
helper for the cJSON_SetNumberValue macro
func (*Node) SetValuestring ¶ added in v0.3.0
Change the valuestring of a cJSON_String object, only takes effect when type of object is cJSON_String
func (*Node) SortObject ¶ added in v0.3.0
func (self *Node) SortObject()
Sorts the members of the object into alphabetical order.
func (*Node) SortObjectCaseSensitive ¶ added in v0.3.0
func (self *Node) SortObjectCaseSensitive()
func (*Node) StringValue ¶ added in v0.3.0
Check item type and return its value