cjson

package
v0.9.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

README

LLGo wrapper of DaveGamble/cJSON

How to install

on macOS (Homebrew)
brew install cjson 
on Linux (Debian/Ubuntu)
apt-get install -y libcjson-dev

Demos

The _demo directory contains our demos (it start with _ to prevent the go command from compiling it):

  • mkjson: create a json object and print it
How to run demos

To run the demos in directory _demo:

cd <demo-directory>  # eg. cd _demo/mkjson
llgo run .

Documentation

Index

Constants

View Source
const (
	LLGoPackage = "link: $(pkg-config --libs libcjson); -lcjson"
)

Variables

This section is empty.

Functions

func Free added in v0.9.3

func Free(ptr unsafe.Pointer)

func FreeCStr added in v0.9.3

func FreeCStr(*c.Char)

Types

type JSON

type JSON struct {
	Unused [0]byte
}

llgo:type C

func Array

func Array() *JSON

func ArrayRef

func ArrayRef(child *JSON) *JSON

Create an array that only references it's elements so they will not be freed by Delete

func Bool

func Bool(boolean c.Int) *JSON

func False

func False() *JSON

func Null

func Null() *JSON

func Number

func Number(num float64) *JSON

func Object

func Object() *JSON

func ObjectRef

func ObjectRef(child *JSON) *JSON

Create an object that only references it's elements so they will not be freed by Delete

func Parse added in v0.9.3

func Parse(value *c.Char) *JSON

func ParseBytes added in v0.9.3

func ParseBytes(value []byte) *JSON

func ParseString added in v0.9.3

func ParseString(value string) *JSON

func ParseWithLength added in v0.9.3

func ParseWithLength(value *byte, valueLength uintptr) *JSON

func Raw

func Raw(raw *c.Char) *JSON

raw json

func String

func String(str *c.Char) *JSON

func StringRef

func StringRef(str *c.Char) *JSON

Create a string where valuestring references a string so it will not be freed by Delete

func True

func True() *JSON

func (*JSON) AddItem

func (o *JSON) AddItem(item *JSON) c.Int

Append item to the specified array.

llgo:link (*JSON).AddItem C.cJSON_AddItemToArray

func (*JSON) CStr

func (o *JSON) CStr() *c.Char

llgo:link (*JSON).CStr C.cJSON_PrintUnformatted

func (*JSON) Cstr

func (o *JSON) Cstr() *c.Char

Same as CStr. Provided for Go+.

llgo:link (*JSON).Cstr C.cJSON_PrintUnformatted

func (*JSON) Delete

func (o *JSON) Delete()

Delete a JSON entity and all subentities.

llgo:link (*JSON).Delete C.cJSON_Delete

func (*JSON) GetArrayItem added in v0.9.4

func (o *JSON) GetArrayItem(index c.Int) *JSON

llgo:link (*JSON).GetArrayItem C.cJSON_GetArrayItem

func (*JSON) GetArraySize added in v0.9.4

func (o *JSON) GetArraySize() c.Int

llgo:link (*JSON).GetArraySize C.cJSON_GetArraySize

func (*JSON) GetObjectItemCaseSensitive added in v0.9.4

func (o *JSON) GetObjectItemCaseSensitive(key *c.Char) *JSON

llgo:link (*JSON).GetObjectItemCaseSensitive C.cJSON_GetObjectItemCaseSensitive

func (*JSON) GetStringValue added in v0.9.4

func (o *JSON) GetStringValue() *c.Char

llgo:link (*JSON).GetStringValue C.cJSON_GetStringValue

func (*JSON) Print

func (o *JSON) Print() *c.Char

Render a JSON entity to text for transfer/storage.

llgo:link (*JSON).Print C.cJSON_Print

func (*JSON) PrintBuffered

func (o *JSON) PrintBuffered(prebuffer c.Int, fmt c.Int) *c.Char

Render a JSON 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) PrintUnformatted

func (o *JSON) PrintUnformatted() *c.Char

Render a JSON entity to text for transfer/storage without any formatting.

llgo:link (*JSON).PrintUnformatted C.cJSON_PrintUnformatted

func (*JSON) SetItem

func (o *JSON) SetItem(key *c.Char, item *JSON) c.Int

Append item to the specified object.

llgo:link (*JSON).SetItem C.cJSON_AddItemToObject

Directories

Path Synopsis
_demo

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL