Documentation
¶
Index ¶
- Constants
- func FreeCStr(object c.Pointer)
- func GetErrorPtr() *c.Char
- func Malloc(size c.SizeT) c.Pointer
- func Minify(json *c.Char)
- func Version() *c.Char
- type Bool
- type Hooks
- type JSON
- func Array() *JSON
- func CreateBool(boolean Bool) *JSON
- func DoubleArray(numbers *c.Double, count c.Int) *JSON
- func False() *JSON
- func FloatArray(numbers *c.Float, count c.Int) *JSON
- func IntArray(numbers *c.Int, count c.Int) *JSON
- func Null() *JSON
- func Number(num c.Double) *JSON
- func Object() *JSON
- func ObjectRef(child *JSON) *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 Raw(raw *c.Char) *JSON
- func String(string *c.Char) *JSON
- func StringArray(strings **c.Char, count c.Int) *JSON
- func StringRef(string *c.Char) *JSON
- func True() *JSON
- func (recv_ *JSON) AddArrayToObject(name *c.Char) *JSON
- func (recv_ *JSON) AddBoolToObject(name *c.Char, boolean Bool) *JSON
- func (recv_ *JSON) AddFalseToObject(name *c.Char) *JSON
- func (recv_ *JSON) AddItem(item *JSON) Bool
- func (recv_ *JSON) AddItemReferenceToArray(item *JSON) Bool
- func (recv_ *JSON) AddItemReferenceToObject(string *c.Char, item *JSON) Bool
- func (recv_ *JSON) AddItemToObjectCS(string *c.Char, item *JSON) Bool
- func (recv_ *JSON) AddNullToObject(name *c.Char) *JSON
- func (recv_ *JSON) AddNumberToObject(name *c.Char, number c.Double) *JSON
- func (recv_ *JSON) AddObjectToObject(name *c.Char) *JSON
- func (recv_ *JSON) AddPatchToArray(operation *c.Char, path *c.Char, value *JSON)
- func (recv_ *JSON) AddRawToObject(name *c.Char, raw *c.Char) *JSON
- func (recv_ *JSON) AddStringToObject(name *c.Char, string *c.Char) *JSON
- func (recv_ *JSON) AddTrueToObject(name *c.Char) *JSON
- func (recv_ *JSON) ApplyPatches(patches *JSON) c.Int
- func (recv_ *JSON) ApplyPatchesCaseSensitive(patches *JSON) c.Int
- func (recv_ *JSON) CStr() *c.Char
- func (recv_ *JSON) Compare(b *JSON, case_sensitive Bool) Bool
- func (recv_ *JSON) CreateArrayRef() *JSON
- func (recv_ *JSON) Delete()
- func (recv_ *JSON) DeleteItemFromArray(which c.Int)
- func (recv_ *JSON) DeleteItemFromObject(string *c.Char)
- func (recv_ *JSON) DeleteItemFromObjectCaseSensitive(string *c.Char)
- func (recv_ *JSON) DetachItemFromArray(which c.Int) *JSON
- func (recv_ *JSON) DetachItemFromObject(string *c.Char) *JSON
- func (recv_ *JSON) DetachItemFromObjectCaseSensitive(string *c.Char) *JSON
- func (recv_ *JSON) DetachItemViaPointer(item *JSON) *JSON
- func (recv_ *JSON) Duplicate(recurse Bool) *JSON
- func (recv_ *JSON) FindPointerFromObjectTo(target *JSON) *c.Char
- func (recv_ *JSON) GenerateMergePatch(to *JSON) *JSON
- func (recv_ *JSON) GenerateMergePatchCaseSensitive(to *JSON) *JSON
- func (recv_ *JSON) GeneratePatches(to *JSON) *JSON
- func (recv_ *JSON) GeneratePatchesCaseSensitive(to *JSON) *JSON
- func (recv_ *JSON) GetArrayItem(index c.Int) *JSON
- func (recv_ *JSON) GetArraySize() c.Int
- func (recv_ *JSON) GetNumberValue() c.Double
- func (recv_ *JSON) GetObjectItem(string *c.Char) *JSON
- func (recv_ *JSON) GetObjectItemCaseSensitive(string *c.Char) *JSON
- func (recv_ *JSON) GetPointer(pointer *c.Char) *JSON
- func (recv_ *JSON) GetPointerCaseSensitive(pointer *c.Char) *JSON
- func (recv_ *JSON) GetStringValue() *c.Char
- func (recv_ *JSON) HasObjectItem(string *c.Char) Bool
- func (recv_ *JSON) InsertItemInArray(which c.Int, newitem *JSON) Bool
- func (recv_ *JSON) IsArray() Bool
- func (recv_ *JSON) IsBool() Bool
- func (recv_ *JSON) IsFalse() Bool
- func (recv_ *JSON) IsInvalid() Bool
- func (recv_ *JSON) IsNull() Bool
- func (recv_ *JSON) IsNumber() Bool
- func (recv_ *JSON) IsObject() Bool
- func (recv_ *JSON) IsRaw() Bool
- func (recv_ *JSON) IsString() Bool
- func (recv_ *JSON) IsTrue() Bool
- func (recv_ *JSON) MergePatch(patch *JSON) *JSON
- func (recv_ *JSON) MergePatchCaseSensitive(patch *JSON) *JSON
- func (recv_ *JSON) Print() *c.Char
- func (recv_ *JSON) PrintBuffered(prebuffer c.Int, fmt Bool) *c.Char
- func (recv_ *JSON) PrintPreallocated(buffer *c.Char, length c.Int, format Bool) Bool
- func (recv_ *JSON) ReplaceItemInArray(which c.Int, newitem *JSON) Bool
- func (recv_ *JSON) ReplaceItemInObject(string *c.Char, newitem *JSON) Bool
- func (recv_ *JSON) ReplaceItemInObjectCaseSensitive(string *c.Char, newitem *JSON) Bool
- func (recv_ *JSON) ReplaceItemViaPointer(item *JSON, replacement *JSON) Bool
- func (recv_ *JSON) SetItem(string *c.Char, item *JSON) Bool
- func (recv_ *JSON) SetNumberHelper(number c.Double) c.Double
- func (recv_ *JSON) SetValuestring(valuestring *c.Char) *c.Char
- func (recv_ *JSON) SortObject()
- func (recv_ *JSON) SortObjectCaseSensitive()
Constants ¶
const IsReference = 256
const LLGoPackage string = "link: $(pkg-config --libs libcjson libcjson_utils);"
const NESTING_LIMIT = 1000
const StringIsConst = 512
const VERSION_MAJOR = 1
const VERSION_MINOR = 7
const VERSION_PATCH = 18
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 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
}
func CreateBool ¶
func IntArray ¶
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 ObjectRef ¶
Create an object/array that only references it's elements so * they will not be freed by cJSON_Delete
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 StringRef ¶
Create a string where valuestring references a string so * it will not be freed by cJSON_Delete
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) AddItem ¶
Append item to the specified array/object.
llgo:link (*JSON).AddItem C.cJSON_AddItemToArray
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) 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 ¶
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 ¶
Returns 0 for success.
llgo:link (*JSON).ApplyPatches C.cJSONUtils_ApplyPatches
func (*JSON) ApplyPatchesCaseSensitive ¶
llgo:link (*JSON).ApplyPatchesCaseSensitive C.cJSONUtils_ApplyPatchesCaseSensitive
func (*JSON) CStr ¶
Render a cJSON entity to text for transfer/storage without any formatting.
llgo:link (*JSON).CStr C.cJSON_PrintUnformatted
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) CreateArrayRef ¶
llgo:link (*JSON).CreateArrayRef C.cJSON_CreateArrayReference
func (*JSON) Delete ¶
func (recv_ *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 ¶
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 ¶
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 ¶
llgo:link (*JSON).GenerateMergePatchCaseSensitive C.cJSONUtils_GenerateMergePatchCaseSensitive
func (*JSON) GeneratePatches ¶
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 ¶
llgo:link (*JSON).GeneratePatchesCaseSensitive C.cJSONUtils_GeneratePatchesCaseSensitive
func (*JSON) GetArrayItem ¶
Retrieve item number "index" from array "array". Returns NULL if unsuccessful.
llgo:link (*JSON).GetArrayItem C.cJSON_GetArrayItem
func (*JSON) GetArraySize ¶
Returns the number of items in an array (or object).
llgo:link (*JSON).GetArraySize C.cJSON_GetArraySize
func (*JSON) GetNumberValue ¶
llgo:link (*JSON).GetNumberValue C.cJSON_GetNumberValue
func (*JSON) GetObjectItem ¶
Get item "string" from object. Case insensitive.
llgo:link (*JSON).GetObjectItem C.cJSON_GetObjectItem
func (*JSON) GetObjectItemCaseSensitive ¶
llgo:link (*JSON).GetObjectItemCaseSensitive C.cJSON_GetObjectItemCaseSensitive
func (*JSON) GetPointer ¶
Implement RFC6901 (https://tools.ietf.org/html/rfc6901) JSON Pointer spec.
llgo:link (*JSON).GetPointer C.cJSONUtils_GetPointer
func (*JSON) GetPointerCaseSensitive ¶
llgo:link (*JSON).GetPointerCaseSensitive C.cJSONUtils_GetPointerCaseSensitive
func (*JSON) GetStringValue ¶
Check item type and return its value
llgo:link (*JSON).GetStringValue C.cJSON_GetStringValue
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 ¶
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 ¶
llgo:link (*JSON).MergePatchCaseSensitive C.cJSONUtils_MergePatchCaseSensitive
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) 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 ¶
func (recv_ *JSON) SortObject()
Sorts the members of the object into alphabetical order.
llgo:link (*JSON).SortObject C.cJSONUtils_SortObject
func (*JSON) SortObjectCaseSensitive ¶
func (recv_ *JSON) SortObjectCaseSensitive()
llgo:link (*JSON).SortObjectCaseSensitive C.cJSONUtils_SortObjectCaseSensitive