Documentation
¶
Index ¶
- Constants
- func Free(object unsafe.Pointer)
- 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 JSON
- func CreateArray() *JSON
- func CreateBool(boolean Bool) *JSON
- func CreateDoubleArray(numbers *c.Double, count c.Int) *JSON
- func CreateFalse() *JSON
- func CreateFloatArray(numbers *c.Float, count c.Int) *JSON
- func CreateIntArray(numbers *c.Int, count c.Int) *JSON
- func CreateNull() *JSON
- func CreateNumber(num c.Double) *JSON
- func CreateObject() *JSON
- func CreateRaw(raw *c.Char) *JSON
- func CreateString(string *c.Char) *JSON
- func CreateStringArray(strings **c.Char, count c.Int) *JSON
- func CreateStringReference(string *c.Char) *JSON
- func CreateTrue() *JSON
- func Parse(value *c.Char) *JSON
- func ParseWithLength(value *c.Char, buffer_length c.SizeT) *JSON
- func ParseWithLengthOpts(value *c.Char, buffer_length c.SizeT, return_parse_end **c.Char, ...) *JSON
- func ParseWithOpts(value *c.Char, return_parse_end **c.Char, require_null_terminated Bool) *JSON
- func (self *JSON) AddArrayToObject(name *c.Char) *JSON
- func (self *JSON) AddBoolToObject(name *c.Char, boolean Bool) *JSON
- func (self *JSON) AddFalseToObject(name *c.Char) *JSON
- func (self *JSON) AddItemReferenceToArray(item *JSON) Bool
- func (self *JSON) AddItemReferenceToObject(string *c.Char, item *JSON) Bool
- func (self *JSON) AddItemToArray(item *JSON) Bool
- func (self *JSON) AddItemToObject(string *c.Char, item *JSON) Bool
- func (self *JSON) AddItemToObjectCS(string *c.Char, item *JSON) Bool
- func (self *JSON) AddNullToObject(name *c.Char) *JSON
- func (self *JSON) AddNumberToObject(name *c.Char, number c.Double) *JSON
- func (self *JSON) AddObjectToObject(name *c.Char) *JSON
- func (self *JSON) AddPatchToArray(operation *c.Char, path *c.Char, value *JSON)
- func (self *JSON) AddRawToObject(name *c.Char, raw *c.Char) *JSON
- func (self *JSON) AddStringToObject(name *c.Char, string *c.Char) *JSON
- func (self *JSON) AddTrueToObject(name *c.Char) *JSON
- func (self *JSON) ApplyPatches(patches *JSON) c.Int
- func (self *JSON) ApplyPatchesCaseSensitive(patches *JSON) c.Int
- func (self *JSON) ArrayItem(index c.Int) *JSON
- func (self *JSON) ArraySize() c.Int
- func (self *JSON) Compare(b *JSON, case_sensitive Bool) Bool
- func (self *JSON) CreateArrayReference() *JSON
- func (self *JSON) CreateObjectReference() *JSON
- func (self *JSON) Delete()
- func (self *JSON) DeleteItemFromArray(which c.Int)
- func (self *JSON) DeleteItemFromObject(string *c.Char)
- func (self *JSON) DeleteItemFromObjectCaseSensitive(string *c.Char)
- func (self *JSON) DetachItemFromArray(which c.Int) *JSON
- func (self *JSON) DetachItemFromObject(string *c.Char) *JSON
- func (self *JSON) DetachItemFromObjectCaseSensitive(string *c.Char) *JSON
- func (self *JSON) DetachItemViaPointer(item *JSON) *JSON
- func (self *JSON) Duplicate(recurse Bool) *JSON
- func (self *JSON) FindPointerFromObjectTo(target *JSON) *c.Char
- func (self *JSON) GenerateMergePatch(to *JSON) *JSON
- func (self *JSON) GenerateMergePatchCaseSensitive(to *JSON) *JSON
- func (self *JSON) GeneratePatches(to *JSON) *JSON
- func (self *JSON) GeneratePatchesCaseSensitive(to *JSON) *JSON
- func (self *JSON) HasObjectItem(string *c.Char) Bool
- func (self *JSON) InsertItemInArray(which c.Int, newitem *JSON) Bool
- func (self *JSON) IsArray() Bool
- func (self *JSON) IsBool() Bool
- func (self *JSON) IsFalse() Bool
- func (self *JSON) IsInvalid() Bool
- func (self *JSON) IsNull() Bool
- func (self *JSON) IsNumber() Bool
- func (self *JSON) IsObject() Bool
- func (self *JSON) IsRaw() Bool
- func (self *JSON) IsString() Bool
- func (self *JSON) IsTrue() Bool
- func (self *JSON) MergePatch(patch *JSON) *JSON
- func (self *JSON) MergePatchCaseSensitive(patch *JSON) *JSON
- func (self *JSON) NumberValue() c.Double
- func (self *JSON) ObjectItem(string *c.Char) *JSON
- func (self *JSON) ObjectItemCaseSensitive(string *c.Char) *JSON
- func (self *JSON) Pointer(pointer *c.Char) *JSON
- func (self *JSON) PointerCaseSensitive(pointer *c.Char) *JSON
- func (self *JSON) Print() *c.Char
- func (self *JSON) PrintBuffered(prebuffer c.Int, fmt Bool) *c.Char
- func (self *JSON) PrintPreallocated(buffer *c.Char, length c.Int, format Bool) Bool
- func (self *JSON) PrintUnformatted() *c.Char
- func (self *JSON) ReplaceItemInArray(which c.Int, newitem *JSON) Bool
- func (self *JSON) ReplaceItemInObject(string *c.Char, newitem *JSON) Bool
- func (self *JSON) ReplaceItemInObjectCaseSensitive(string *c.Char, newitem *JSON) Bool
- func (self *JSON) ReplaceItemViaPointer(item *JSON, replacement *JSON) Bool
- func (self *JSON) SetNumberHelper(number c.Double) c.Double
- func (self *JSON) SetValuestring(valuestring *c.Char) *c.Char
- func (self *JSON) SortObject()
- func (self *JSON) SortObjectCaseSensitive()
- func (self *JSON) StringValue() *c.Char
Constants ¶
const Array = 32
const CIRCULAR_LIMIT = 10000
const False = 1
const Invalid = 0
const IsReference = 256
const LLGoPackage = "link: $(pkg-config --libs libcjson_utils); -lcjson_utils -lcjson"
const NESTING_LIMIT = 1000
const NULL = 4
const Number = 8
const Object = 64
const Raw = 128
const String = 16
const StringIsConst = 512
const True = 2
const VERSION_MAJOR = 1
const VERSION_MINOR = 7
const VERSION_PATCH = 19
Variables ¶
This section is empty.
Functions ¶
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 Hooks struct {
MallocFn func(_llcppg_param1 c.SizeT) unsafe.Pointer
FreeFn func(_llcppg_param1 unsafe.Pointer)
}
llgo:type C
type JSON ¶
type JSON struct {
Next *JSON
Prev *JSON
Child *JSON
Type c.Int
Valuestring *c.Char
Valueint c.Int
Valuedouble c.Double
String *c.Char
}
The cJSON structure:
func CreateArray ¶
func CreateArray() *JSON
func CreateBool ¶
func CreateFalse ¶
func CreateFalse() *JSON
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() *JSON
func CreateString ¶
func CreateStringReference ¶
Create a string where valuestring references a string so it will not be freed by cJSON_Delete
func CreateTrue ¶
func CreateTrue() *JSON
func Parse ¶
Memory Management: the caller is always responsible to free the results from all variants of cJSON_Parse (with cJSON_Delete) and cJSON_Print (with stdlib free, cJSON_Hooks.free_fn, or cJSON_free as appropriate). The exception is cJSON_PrintPreallocated, where the caller has full responsibility of the buffer. Supply a block of JSON, and this returns a cJSON object you can interrogate.
func ParseWithLengthOpts ¶
func ParseWithOpts ¶
ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. 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 (*JSON) AddArrayToObject ¶
llgo:link (*JSON).AddArrayToObject C.cJSON_AddArrayToObject
func (*JSON) AddBoolToObject ¶
llgo:link (*JSON).AddBoolToObject C.cJSON_AddBoolToObject
func (*JSON) AddFalseToObject ¶
llgo:link (*JSON).AddFalseToObject C.cJSON_AddFalseToObject
func (*JSON) AddItemReferenceToArray ¶
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.
llgo:link (*JSON).AddItemReferenceToArray C.cJSON_AddItemReferenceToArray
func (*JSON) AddItemReferenceToObject ¶
llgo:link (*JSON).AddItemReferenceToObject C.cJSON_AddItemReferenceToObject
func (*JSON) AddItemToArray ¶
Append item to the specified array/object.
llgo:link (*JSON).AddItemToArray C.cJSON_AddItemToArray
func (*JSON) AddItemToObject ¶
llgo:link (*JSON).AddItemToObject C.cJSON_AddItemToObject
func (*JSON) AddItemToObjectCS ¶
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`
llgo:link (*JSON).AddItemToObjectCS C.cJSON_AddItemToObjectCS
func (*JSON) AddNullToObject ¶
Helper functions for creating and adding items to an object at the same time. They return the added item or NULL on failure.
llgo:link (*JSON).AddNullToObject C.cJSON_AddNullToObject
func (*JSON) AddNumberToObject ¶
llgo:link (*JSON).AddNumberToObject C.cJSON_AddNumberToObject
func (*JSON) AddObjectToObject ¶
llgo:link (*JSON).AddObjectToObject C.cJSON_AddObjectToObject
func (*JSON) AddPatchToArray ¶ added in v0.1.1
Utility for generating patch array entries.
llgo:link (*JSON).AddPatchToArray C.cJSONUtils_AddPatchToArray
func (*JSON) AddRawToObject ¶
llgo:link (*JSON).AddRawToObject C.cJSON_AddRawToObject
func (*JSON) AddStringToObject ¶
llgo:link (*JSON).AddStringToObject C.cJSON_AddStringToObject
func (*JSON) AddTrueToObject ¶
llgo:link (*JSON).AddTrueToObject C.cJSON_AddTrueToObject
func (*JSON) ApplyPatches ¶ added in v0.1.1
Returns 0 for success.
llgo:link (*JSON).ApplyPatches C.cJSONUtils_ApplyPatches
func (*JSON) ApplyPatchesCaseSensitive ¶ added in v0.1.1
llgo:link (*JSON).ApplyPatchesCaseSensitive C.cJSONUtils_ApplyPatchesCaseSensitive
func (*JSON) ArrayItem ¶
Retrieve item number "index" from array "array". Returns NULL if unsuccessful.
llgo:link (*JSON).ArrayItem C.cJSON_GetArrayItem
func (*JSON) ArraySize ¶
Returns the number of items in an array (or object).
llgo:link (*JSON).ArraySize C.cJSON_GetArraySize
func (*JSON) Compare ¶
Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will need to be released. With recurse!=0, it will duplicate any children connected to the item. The item->next and ->prev pointers are always zero on return from Duplicate. 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)
llgo:link (*JSON).Compare C.cJSON_Compare
func (*JSON) CreateArrayReference ¶
llgo:link (*JSON).CreateArrayReference C.cJSON_CreateArrayReference
func (*JSON) CreateObjectReference ¶
Create an object/array that only references it's elements so they will not be freed by cJSON_Delete
llgo:link (*JSON).CreateObjectReference C.cJSON_CreateObjectReference
func (*JSON) Delete ¶
func (self *JSON) Delete()
Delete a cJSON entity and all subentities.
llgo:link (*JSON).Delete C.cJSON_Delete
func (*JSON) DeleteItemFromArray ¶
llgo:link (*JSON).DeleteItemFromArray C.cJSON_DeleteItemFromArray
func (*JSON) DeleteItemFromObject ¶
llgo:link (*JSON).DeleteItemFromObject C.cJSON_DeleteItemFromObject
func (*JSON) DeleteItemFromObjectCaseSensitive ¶
llgo:link (*JSON).DeleteItemFromObjectCaseSensitive C.cJSON_DeleteItemFromObjectCaseSensitive
func (*JSON) DetachItemFromArray ¶
llgo:link (*JSON).DetachItemFromArray C.cJSON_DetachItemFromArray
func (*JSON) DetachItemFromObject ¶
llgo:link (*JSON).DetachItemFromObject C.cJSON_DetachItemFromObject
func (*JSON) DetachItemFromObjectCaseSensitive ¶
llgo:link (*JSON).DetachItemFromObjectCaseSensitive C.cJSON_DetachItemFromObjectCaseSensitive
func (*JSON) DetachItemViaPointer ¶
Remove/Detach items from Arrays/Objects.
llgo:link (*JSON).DetachItemViaPointer C.cJSON_DetachItemViaPointer
func (*JSON) FindPointerFromObjectTo ¶ added in v0.1.1
Given a root object and a target object, construct a pointer from one to the other.
llgo:link (*JSON).FindPointerFromObjectTo C.cJSONUtils_FindPointerFromObjectTo
func (*JSON) GenerateMergePatch ¶ added in v0.1.1
generates a patch to move from -> to NOTE: This modifies objects in 'from' and 'to' by sorting the elements by their key
llgo:link (*JSON).GenerateMergePatch C.cJSONUtils_GenerateMergePatch
func (*JSON) GenerateMergePatchCaseSensitive ¶ added in v0.1.1
llgo:link (*JSON).GenerateMergePatchCaseSensitive C.cJSONUtils_GenerateMergePatchCaseSensitive
func (*JSON) GeneratePatches ¶ added in v0.1.1
Implement RFC6902 (https://tools.ietf.org/html/rfc6902) JSON Patch spec. NOTE: This modifies objects in 'from' and 'to' by sorting the elements by their key
llgo:link (*JSON).GeneratePatches C.cJSONUtils_GeneratePatches
func (*JSON) GeneratePatchesCaseSensitive ¶ added in v0.1.1
llgo:link (*JSON).GeneratePatchesCaseSensitive C.cJSONUtils_GeneratePatchesCaseSensitive
func (*JSON) HasObjectItem ¶
llgo:link (*JSON).HasObjectItem C.cJSON_HasObjectItem
func (*JSON) InsertItemInArray ¶
Update array items.
llgo:link (*JSON).InsertItemInArray C.cJSON_InsertItemInArray
func (*JSON) IsInvalid ¶
These functions check the type of an item
llgo:link (*JSON).IsInvalid C.cJSON_IsInvalid
func (*JSON) MergePatch ¶ added in v0.1.1
Implement RFC7386 (https://tools.ietf.org/html/rfc7396) JSON Merge Patch spec. target will be modified by patch. return value is new ptr for target.
llgo:link (*JSON).MergePatch C.cJSONUtils_MergePatch
func (*JSON) MergePatchCaseSensitive ¶ added in v0.1.1
llgo:link (*JSON).MergePatchCaseSensitive C.cJSONUtils_MergePatchCaseSensitive
func (*JSON) NumberValue ¶
llgo:link (*JSON).NumberValue C.cJSON_GetNumberValue
func (*JSON) ObjectItem ¶
Get item "string" from object. Case insensitive.
llgo:link (*JSON).ObjectItem C.cJSON_GetObjectItem
func (*JSON) ObjectItemCaseSensitive ¶
llgo:link (*JSON).ObjectItemCaseSensitive C.cJSON_GetObjectItemCaseSensitive
func (*JSON) Pointer ¶ added in v0.1.1
Implement RFC6901 (https://tools.ietf.org/html/rfc6901) JSON Pointer spec.
llgo:link (*JSON).Pointer C.cJSONUtils_GetPointer
func (*JSON) PointerCaseSensitive ¶ added in v0.1.1
llgo:link (*JSON).PointerCaseSensitive C.cJSONUtils_GetPointerCaseSensitive
func (*JSON) Print ¶
Render a cJSON entity to text for transfer/storage.
llgo:link (*JSON).Print C.cJSON_Print
func (*JSON) PrintBuffered ¶
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
llgo:link (*JSON).PrintBuffered C.cJSON_PrintBuffered
func (*JSON) PrintPreallocated ¶
Render a cJSON entity to text using a buffer already allocated in memory with given length. Returns 1 on success and 0 on failure. 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
llgo:link (*JSON).PrintPreallocated C.cJSON_PrintPreallocated
func (*JSON) PrintUnformatted ¶
Render a cJSON entity to text for transfer/storage without any formatting.
llgo:link (*JSON).PrintUnformatted C.cJSON_PrintUnformatted
func (*JSON) ReplaceItemInArray ¶
llgo:link (*JSON).ReplaceItemInArray C.cJSON_ReplaceItemInArray
func (*JSON) ReplaceItemInObject ¶
llgo:link (*JSON).ReplaceItemInObject C.cJSON_ReplaceItemInObject
func (*JSON) ReplaceItemInObjectCaseSensitive ¶
llgo:link (*JSON).ReplaceItemInObjectCaseSensitive C.cJSON_ReplaceItemInObjectCaseSensitive
func (*JSON) ReplaceItemViaPointer ¶
llgo:link (*JSON).ReplaceItemViaPointer C.cJSON_ReplaceItemViaPointer
func (*JSON) SetNumberHelper ¶
helper for the cJSON_SetNumberValue macro
llgo:link (*JSON).SetNumberHelper C.cJSON_SetNumberHelper
func (*JSON) SetValuestring ¶
Change the valuestring of a cJSON_String object, only takes effect when type of object is cJSON_String
llgo:link (*JSON).SetValuestring C.cJSON_SetValuestring
func (*JSON) SortObject ¶ added in v0.1.1
func (self *JSON) SortObject()
Sorts the members of the object into alphabetical order.
llgo:link (*JSON).SortObject C.cJSONUtils_SortObject
func (*JSON) SortObjectCaseSensitive ¶ added in v0.1.1
func (self *JSON) SortObjectCaseSensitive()
llgo:link (*JSON).SortObjectCaseSensitive C.cJSONUtils_SortObjectCaseSensitive
func (*JSON) StringValue ¶
Check item type and return its value
llgo:link (*JSON).StringValue C.cJSON_GetStringValue