Documentation
¶
Index ¶
- func Equal(a, b Json) bool
- func EscapePointerSeg(ptr string) string
- func Extract(json interface{}, ptr string) (interface{}, error)
- func IsBJson(data []byte) bool
- func IsJSON(bs []byte) bool
- func IsNull(value Json) bool
- func Marshal(j Json) ([]byte, error)
- func NewPointer(segs []string) string
- func ParsePointer(ptr string) ([]string, error)
- func PathSegments(path string) []string
- func UnescapePointerSeg(ptr string) string
- func Unmarshal(data Json, v interface{}) error
- func UnmarshalUseNumber(data Json, v interface{}) error
- type Array
- type ArrayBinary
- func (a ArrayBinary) AST() ast.Value
- func (a ArrayBinary) Append(elements ...File) Array
- func (a ArrayBinary) AppendSingle(element File) (Array, bool)
- func (a ArrayBinary) Clone(bool) File
- func (a ArrayBinary) Compare(other Json) int
- func (a ArrayBinary) Contents() interface{}
- func (a ArrayBinary) Extract(ptr string) (Json, error)
- func (a ArrayBinary) Iterate(i int) Json
- func (a ArrayBinary) JSON() interface{}
- func (a ArrayBinary) Len() int
- func (a ArrayBinary) RemoveIdx(i int) Json
- func (a ArrayBinary) SetIdx(i int, value File) Json
- func (a ArrayBinary) Slice(i int, j int) Array
- func (a ArrayBinary) String() string
- func (a ArrayBinary) Value(i int) Json
- func (a ArrayBinary) WriteI(w io.Writer, i int, written *int64) error
- func (a ArrayBinary) WriteTo(w io.Writer) (int64, error)
- type ArraySlice
- func (a *ArraySlice) AST() ast.Value
- func (a *ArraySlice) Append(elements ...File) Array
- func (a *ArraySlice) AppendSingle(element File) (Array, bool)
- func (a *ArraySlice) Clone(deepCopy bool) File
- func (a *ArraySlice) Compare(other Json) int
- func (a *ArraySlice) Contents() interface{}
- func (a *ArraySlice) Extract(ptr string) (Json, error)
- func (a *ArraySlice) Iterate(i int) Json
- func (a *ArraySlice) JSON() interface{}
- func (a *ArraySlice) Len() int
- func (a *ArraySlice) RemoveIdx(i int) Json
- func (a *ArraySlice) SetIdx(i int, j File) Json
- func (a *ArraySlice) Slice(i, j int) Array
- func (a *ArraySlice) String() string
- func (a *ArraySlice) Value(i int) Json
- func (a *ArraySlice) WriteI(w io.Writer, i int, written *int64) error
- func (a *ArraySlice) WriteTo(w io.Writer) (int64, error)
- type ArraySliceCompact
- func (a *ArraySliceCompact[T]) AST() ast.Value
- func (a *ArraySliceCompact[T]) Append(elements ...File) Array
- func (a *ArraySliceCompact[T]) AppendSingle(element File) (Array, bool)
- func (a *ArraySliceCompact[T]) Clone(deepCopy bool) File
- func (a *ArraySliceCompact[T]) Compare(other Json) int
- func (a *ArraySliceCompact[T]) Contents() interface{}
- func (a *ArraySliceCompact[T]) Extract(ptr string) (Json, error)
- func (a *ArraySliceCompact[T]) Iterate(i int) Json
- func (a *ArraySliceCompact[T]) JSON() interface{}
- func (a *ArraySliceCompact[T]) Len() int
- func (a *ArraySliceCompact[T]) RemoveIdx(i int) Json
- func (a *ArraySliceCompact[T]) SetIdx(i int, j File) Json
- func (a *ArraySliceCompact[T]) Slice(i, j int) Array
- func (a *ArraySliceCompact[T]) String() string
- func (a *ArraySliceCompact[T]) Value(i int) Json
- func (a *ArraySliceCompact[T]) WriteI(w io.Writer, i int, written *int64) error
- func (a *ArraySliceCompact[T]) WriteTo(w io.Writer) (int64, error)
- type ArraySliceCompactStrings
- func (a *ArraySliceCompactStrings[T]) AST() ast.Value
- func (a *ArraySliceCompactStrings[T]) Append(elements ...File) Array
- func (a *ArraySliceCompactStrings[T]) AppendSingle(element File) (Array, bool)
- func (a *ArraySliceCompactStrings[T]) Clone(deepCopy bool) File
- func (a *ArraySliceCompactStrings[T]) Compare(other Json) int
- func (a *ArraySliceCompactStrings[T]) Contents() interface{}
- func (a *ArraySliceCompactStrings[T]) Extract(ptr string) (Json, error)
- func (a *ArraySliceCompactStrings[T]) Iterate(i int) Json
- func (a *ArraySliceCompactStrings[T]) JSON() interface{}
- func (a *ArraySliceCompactStrings[T]) Len() int
- func (a *ArraySliceCompactStrings[T]) RemoveIdx(i int) Json
- func (a *ArraySliceCompactStrings[T]) SetIdx(i int, j File) Json
- func (a *ArraySliceCompactStrings[T]) Slice(i, j int) Array
- func (a *ArraySliceCompactStrings[T]) String() string
- func (a *ArraySliceCompactStrings[T]) Value(i int) Json
- func (a *ArraySliceCompactStrings[T]) WriteI(w io.Writer, i int, written *int64) error
- func (a *ArraySliceCompactStrings[T]) WriteTo(w io.Writer) (int64, error)
- type Blob
- type Bool
- func (b Bool) AST() ast.Value
- func (b Bool) Clone(bool) File
- func (b Bool) Compare(other Json) int
- func (b Bool) Contents() interface{}
- func (b Bool) Extract(ptr string) (Json, error)
- func (b Bool) JSON() interface{}
- func (b Bool) String() string
- func (b Bool) Value() bool
- func (b Bool) WriteTo(w io.Writer) (int64, error)
- type Collections
- type Decoder
- type File
- type Float
- func (f Float) AST() ast.Value
- func (f Float) Add(addition Float) Float
- func (f Float) Clone(bool) File
- func (f Float) Compare(other Json) int
- func (f Float) Contents() interface{}
- func (f Float) Divide(divisor Float) Float
- func (f Float) Extract(ptr string) (Json, error)
- func (f Float) JSON() interface{}
- func (f Float) Multiply(multiplier Float) Float
- func (f Float) String() string
- func (f Float) Sub(decrement Float) Float
- func (f Float) Value() gojson.Number
- func (f Float) WriteTo(w io.Writer) (int64, error)
- type Iterable
- type Json
- type JsonPatchSpec
- type JsonPatchTestFailed
- type Kind
- type Null
- type Object
- type Object2
- type ObjectBinary
- func (o ObjectBinary) AST() ast.Value
- func (o ObjectBinary) Clone(bool) File
- func (o ObjectBinary) Compare(other Json) int
- func (o ObjectBinary) Contents() interface{}
- func (o ObjectBinary) Extract(ptr string) (Json, error)
- func (o ObjectBinary) Iterate(i int) Json
- func (o ObjectBinary) JSON() interface{}
- func (o ObjectBinary) Len() int
- func (o ObjectBinary) Names() []string
- func (o ObjectBinary) NamesIndex(i int) string
- func (o ObjectBinary) Remove(name string) Object
- func (o ObjectBinary) RemoveIdx(i int) Json
- func (o ObjectBinary) Serialize(cache *encodingCache, buffer *bytes.Buffer, base int32) (int32, error)
- func (o ObjectBinary) Set(name string, value Json) (Object, bool)
- func (o ObjectBinary) SetIdx(i int, value File) Json
- func (o ObjectBinary) String() string
- func (o ObjectBinary) Union(other Json) Json
- func (o ObjectBinary) Value(name string) Json
- func (o ObjectBinary) WriteTo(w io.Writer) (int64, error)
- type ObjectMap
- func (o *ObjectMap) AST() ast.Value
- func (o *ObjectMap) Clone(deepCopy bool) File
- func (o *ObjectMap) Compare(other Json) int
- func (o *ObjectMap) Contents() interface{}
- func (o *ObjectMap) Extract(ptr string) (Json, error)
- func (o *ObjectMap) Iterate(i int) Json
- func (o *ObjectMap) JSON() interface{}
- func (o *ObjectMap) Len() int
- func (o *ObjectMap) Names() []string
- func (o *ObjectMap) Remove(name string) Object
- func (o *ObjectMap) RemoveIdx(i int) Json
- func (o *ObjectMap) Serialize(cache *encodingCache, buffer *bytes.Buffer, base int32) (int32, error)
- func (o *ObjectMap) Set(name string, value Json) (Object, bool)
- func (o *ObjectMap) SetIdx(i int, j File) Json
- func (o *ObjectMap) String() string
- func (o *ObjectMap) Union(other Json) Json
- func (o *ObjectMap) Value(name string) Json
- func (o *ObjectMap) WriteTo(w io.Writer) (int64, error)
- type ObjectMapCompact
- func (o *ObjectMapCompact[T]) AST() ast.Value
- func (o *ObjectMapCompact[T]) Clone(deepCopy bool) File
- func (o *ObjectMapCompact[T]) Compare(other Json) int
- func (o *ObjectMapCompact[T]) Contents() interface{}
- func (o *ObjectMapCompact[T]) Extract(ptr string) (Json, error)
- func (o *ObjectMapCompact[T]) Iterate(i int) Json
- func (o *ObjectMapCompact[T]) JSON() interface{}
- func (o *ObjectMapCompact[T]) Len() int
- func (o *ObjectMapCompact[T]) Names() []string
- func (o *ObjectMapCompact[T]) Remove(name string) Object
- func (o *ObjectMapCompact[T]) RemoveIdx(i int) Json
- func (o *ObjectMapCompact[T]) Serialize(cache *encodingCache, buffer *bytes.Buffer, base int32) (int32, error)
- func (o *ObjectMapCompact[T]) Set(name string, value Json) (Object, bool)
- func (o *ObjectMapCompact[T]) SetIdx(i int, j File) Json
- func (o *ObjectMapCompact[T]) String() string
- func (o *ObjectMapCompact[T]) Union(other Json) Json
- func (o *ObjectMapCompact[T]) Value(name string) Json
- func (o *ObjectMapCompact[T]) WriteTo(w io.Writer) (int64, error)
- type ObjectMapCompactStrings
- func (o *ObjectMapCompactStrings[T]) AST() ast.Value
- func (o *ObjectMapCompactStrings[T]) Clone(bool) File
- func (o *ObjectMapCompactStrings[T]) Compare(other Json) int
- func (o *ObjectMapCompactStrings[T]) Contents() interface{}
- func (o *ObjectMapCompactStrings[T]) Extract(ptr string) (Json, error)
- func (o *ObjectMapCompactStrings[T]) Iterate(i int) Json
- func (o *ObjectMapCompactStrings[T]) JSON() interface{}
- func (o *ObjectMapCompactStrings[T]) Len() int
- func (o *ObjectMapCompactStrings[T]) Names() []string
- func (o *ObjectMapCompactStrings[T]) Remove(name string) Object
- func (o *ObjectMapCompactStrings[T]) RemoveIdx(i int) Json
- func (o *ObjectMapCompactStrings[T]) Serialize(cache *encodingCache, buffer *bytes.Buffer, base int32) (int32, error)
- func (o *ObjectMapCompactStrings[T]) Set(name string, value Json) (Object, bool)
- func (o *ObjectMapCompactStrings[T]) SetIdx(i int, j File) Json
- func (o *ObjectMapCompactStrings[T]) String() string
- func (o *ObjectMapCompactStrings[T]) Union(other Json) Json
- func (o *ObjectMapCompactStrings[T]) Value(name string) Json
- func (o *ObjectMapCompactStrings[T]) WriteTo(w io.Writer) (int64, error)
- type Op
- type Patch
- type PatchOp
- type Resource
- type Set
- type String
- func (s *String) AST() ast.Value
- func (s *String) Clone(bool) File
- func (s *String) Compare(other Json) int
- func (s *String) Contents() interface{}
- func (s *String) Extract(ptr string) (Json, error)
- func (s *String) JSON() interface{}
- func (s *String) String() string
- func (s *String) Value() string
- func (s *String) WriteTo(w io.Writer) (int64, error)
- type T
- type WritableCollections
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EscapePointerSeg ¶
escapePointerSeg escapes a string to be safe string for a path segment.
func Extract ¶
Extract returns a value from an JSON document as per RFC 6901 pointer string.
The function returns an error if no element found (to separate from the case value being a nil). That is, it is up to the caller to determine the exact semantics of no element found.
func NewPointer ¶
NewPointer constructs a JSON pointer from its segments.
func ParsePointer ¶
ParsePointer parses a JSON pointer, returning its segments.
func PathSegments ¶
PathSegments returns the path segments of the path.
func UnescapePointerSeg ¶
unescapePointerSeg unescapes a path segment.
func UnmarshalUseNumber ¶
UnmarshalUseNumber stores the JSON data in the value pointed to by v. Numbers are stored as json.Number
Types ¶
type Array ¶
type Array interface {
Json
Iterable
Append(element ...File) Array
AppendSingle(element File) (Array, bool)
Slice(i, j int) Array
Value(i int) Json
WriteI(w io.Writer, i int, written *int64) error
// contains filtered or unexported methods
}
Array represents a JSON array.
func NewArrayCompactStrings ¶
type ArrayBinary ¶
type ArrayBinary struct {
// contains filtered or unexported fields
}
func (ArrayBinary) AST ¶
func (a ArrayBinary) AST() ast.Value
func (ArrayBinary) Append ¶
func (a ArrayBinary) Append(elements ...File) Array
func (ArrayBinary) AppendSingle ¶
func (a ArrayBinary) AppendSingle(element File) (Array, bool)
func (ArrayBinary) Clone ¶
func (a ArrayBinary) Clone(bool) File
func (ArrayBinary) Compare ¶
func (a ArrayBinary) Compare(other Json) int
func (ArrayBinary) Contents ¶
func (a ArrayBinary) Contents() interface{}
func (ArrayBinary) Iterate ¶
func (a ArrayBinary) Iterate(i int) Json
func (ArrayBinary) JSON ¶
func (a ArrayBinary) JSON() interface{}
func (ArrayBinary) Len ¶
func (a ArrayBinary) Len() int
func (ArrayBinary) RemoveIdx ¶
func (a ArrayBinary) RemoveIdx(i int) Json
func (ArrayBinary) String ¶
func (a ArrayBinary) String() string
func (ArrayBinary) Value ¶
func (a ArrayBinary) Value(i int) Json
type ArraySlice ¶
type ArraySlice struct {
// contains filtered or unexported fields
}
func (*ArraySlice) AST ¶
func (a *ArraySlice) AST() ast.Value
func (*ArraySlice) Append ¶
func (a *ArraySlice) Append(elements ...File) Array
func (*ArraySlice) AppendSingle ¶
func (a *ArraySlice) AppendSingle(element File) (Array, bool)
func (*ArraySlice) Clone ¶
func (a *ArraySlice) Clone(deepCopy bool) File
func (*ArraySlice) Compare ¶
func (a *ArraySlice) Compare(other Json) int
func (*ArraySlice) Contents ¶
func (a *ArraySlice) Contents() interface{}
func (*ArraySlice) Iterate ¶
func (a *ArraySlice) Iterate(i int) Json
func (*ArraySlice) JSON ¶
func (a *ArraySlice) JSON() interface{}
func (*ArraySlice) Len ¶
func (a *ArraySlice) Len() int
func (*ArraySlice) RemoveIdx ¶
func (a *ArraySlice) RemoveIdx(i int) Json
func (*ArraySlice) Slice ¶
func (a *ArraySlice) Slice(i, j int) Array
func (*ArraySlice) String ¶
func (a *ArraySlice) String() string
func (*ArraySlice) Value ¶
func (a *ArraySlice) Value(i int) Json
type ArraySliceCompact ¶
type ArraySliceCompact[T indexable] struct {
// contains filtered or unexported fields
}
ArraySliceCompact is a compact implementation of the arrays with at most 32 elements.
func (*ArraySliceCompact[T]) AST ¶
func (a *ArraySliceCompact[T]) AST() ast.Value
func (*ArraySliceCompact[T]) Append ¶
func (a *ArraySliceCompact[T]) Append(elements ...File) Array
func (*ArraySliceCompact[T]) AppendSingle ¶
func (a *ArraySliceCompact[T]) AppendSingle(element File) (Array, bool)
func (*ArraySliceCompact[T]) Clone ¶
func (a *ArraySliceCompact[T]) Clone(deepCopy bool) File
func (*ArraySliceCompact[T]) Compare ¶
func (a *ArraySliceCompact[T]) Compare(other Json) int
func (*ArraySliceCompact[T]) Contents ¶
func (a *ArraySliceCompact[T]) Contents() interface{}
func (*ArraySliceCompact[T]) Extract ¶
func (a *ArraySliceCompact[T]) Extract(ptr string) (Json, error)
func (*ArraySliceCompact[T]) Iterate ¶
func (a *ArraySliceCompact[T]) Iterate(i int) Json
func (*ArraySliceCompact[T]) JSON ¶
func (a *ArraySliceCompact[T]) JSON() interface{}
func (*ArraySliceCompact[T]) Len ¶
func (a *ArraySliceCompact[T]) Len() int
func (*ArraySliceCompact[T]) RemoveIdx ¶
func (a *ArraySliceCompact[T]) RemoveIdx(i int) Json
func (*ArraySliceCompact[T]) Slice ¶
func (a *ArraySliceCompact[T]) Slice(i, j int) Array
func (*ArraySliceCompact[T]) String ¶
func (a *ArraySliceCompact[T]) String() string
func (*ArraySliceCompact[T]) Value ¶
func (a *ArraySliceCompact[T]) Value(i int) Json
type ArraySliceCompactStrings ¶
type ArraySliceCompactStrings[T indexableStrings] struct {
// contains filtered or unexported fields
}
ArraySliceCompactStrings is a compact implementation of the string arrays with at most 32 elements.
func (*ArraySliceCompactStrings[T]) AST ¶
func (a *ArraySliceCompactStrings[T]) AST() ast.Value
func (*ArraySliceCompactStrings[T]) Append ¶
func (a *ArraySliceCompactStrings[T]) Append(elements ...File) Array
func (*ArraySliceCompactStrings[T]) AppendSingle ¶
func (a *ArraySliceCompactStrings[T]) AppendSingle(element File) (Array, bool)
func (*ArraySliceCompactStrings[T]) Clone ¶
func (a *ArraySliceCompactStrings[T]) Clone(deepCopy bool) File
func (*ArraySliceCompactStrings[T]) Compare ¶
func (a *ArraySliceCompactStrings[T]) Compare(other Json) int
func (*ArraySliceCompactStrings[T]) Contents ¶
func (a *ArraySliceCompactStrings[T]) Contents() interface{}
func (*ArraySliceCompactStrings[T]) Extract ¶
func (a *ArraySliceCompactStrings[T]) Extract(ptr string) (Json, error)
func (*ArraySliceCompactStrings[T]) Iterate ¶
func (a *ArraySliceCompactStrings[T]) Iterate(i int) Json
func (*ArraySliceCompactStrings[T]) JSON ¶
func (a *ArraySliceCompactStrings[T]) JSON() interface{}
func (*ArraySliceCompactStrings[T]) Len ¶
func (a *ArraySliceCompactStrings[T]) Len() int
func (*ArraySliceCompactStrings[T]) RemoveIdx ¶
func (a *ArraySliceCompactStrings[T]) RemoveIdx(i int) Json
func (*ArraySliceCompactStrings[T]) SetIdx ¶
func (a *ArraySliceCompactStrings[T]) SetIdx(i int, j File) Json
func (*ArraySliceCompactStrings[T]) Slice ¶
func (a *ArraySliceCompactStrings[T]) Slice(i, j int) Array
func (*ArraySliceCompactStrings[T]) String ¶
func (a *ArraySliceCompactStrings[T]) String() string
func (*ArraySliceCompactStrings[T]) Value ¶
func (a *ArraySliceCompactStrings[T]) Value(i int) Json
type Bool ¶
type Bool struct {
// contains filtered or unexported fields
}
Bool represents a JSON boolean value.
type Collections ¶
type Collections interface {
// Resource returns resource meta data for a particular resource. Returns nil if no resource matches the name.
Resource(name string) Resource
// Collections returns all JSON collections available.
Collections() []string
// Walk executes a depth-first search over the snapshot, stopping the recursion (but not the entire walk) if the callback returns false.
Walk(func(resource Resource) bool)
// Diff computes a binary diff against collections provided and returns a reader for consuming the computed diff together with the number of bytes available. Boolean value is true
// if the diff is empty.
Diff(other Collections) (*utils.BytesReader, int64, bool, error)
// Writable returns a writable copy of the collections.
Writable() WritableCollections
// Len returns the # of bytes in binary level representation.
Len() int64
// Reader returns a binary level reader for the entire collection.
Reader() *utils.MultiReader
// DeltaReader returns a binary level reader for the delta of the collection, if a delta collection.
DeltaReader() *utils.MultiReader
io.WriterTo
// Objects returns the storage objects below. If a snapshot based collection, the slice will hold only one entry, the snapshot object. If a
// delta based collection, the first entity will be the delta object and the second for the snapshot. Note the meta data may be nil, if it was not provided at the construction time.
Objects() []interface{}
// WriteBlob replaces the contents of a binary resource.
WriteBlob(name string, blob Blob)
// WriteJSON replaces the contents of a JSON resource.
WriteJSON(name string, j Json)
// PatchJSON applies a patch to a JSON resource.
PatchJSON(name string, patch Patch) (bool, error)
// WriteDirectory creates a directory.
WriteDirectory(name string)
// Remove removes a resource. It returns true if found and successfully removed. It does not remove a directory if it's not empty.
Remove(name string) bool
// Writes a meta key-value pair for a resource, returning if successful. Note, the resource has to exist this to take effect.
WriteMeta(name string, key string, value string) bool
}
Collections represents a logical snapshot of hierarchical resources coming from a single data source. Internally it is binary encoded, and it may use delta encoding for compact representation.
func NewCollectionsFromReaders ¶
func NewCollectionsFromReaders(snapshotReader *utils.MultiReader, slen int64, dr *utils.MultiReader, dlen int64, objects ...interface{}) (collections Collections, err error)
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder mimics the golang JSON decoder: reading a JSON object out of a byte stream. For simplicity, the Decode() implementation returns the constructed object, instead of taking a pointer as a parameter as the standard package.
func NewDecoder ¶
func NewStringDecoder ¶
func (*Decoder) UnmarshalArray ¶
func (*Decoder) UnmarshalObject ¶
func (*Decoder) UnmarshalString ¶
type File ¶
type File interface {
io.WriterTo
Contents() interface{}
// Clone returns a (deep) copy of the file.
Clone(deepCopy bool) File
}
File is the interface all files (structured or unstructured) stored to the snapshot implement. It is for accessing the contents of the file only; the metadata is to be accessed over the Resource interface (which represents a single entity in the namespace).
type Float ¶
type Float struct {
// contains filtered or unexported fields
}
Float represents a JSON float value.
func NewFloatInt ¶
type Iterable ¶
type Iterable interface {
Len() int
Iterate(i int) Json
RemoveIdx(i int) Json
SetIdx(i int, j File) Json
// contains filtered or unexported methods
}
Iterable is implemented by both Arrays and Objects.
type Json ¶
type Json interface {
File
fmt.Stringer
// JSON returns Go JSON object. This is same as File.Contents().
JSON() interface{}
// AST return OPA ast.Value.
AST() ast.Value
// Extract returns the JSON element the provided JSON pointer (RFC 6901) refers to. The function returns an error if no element found.
Extract(ptr string) (Json, error)
// Compare compares this JSON node ('a') to another JSON ('b'), returning -1, 0, 1 if 'a' is less than 'b', 'a' equals to 'b', or 'a' is more than 'b', respectively.
Compare(other Json) int
// contains filtered or unexported methods
}
Json is the interface every element within the document implements.
func MustNew ¶
func MustNew(value interface{}) Json
MustNew constructs a JSON object out of go native types. It supports the struct tags. It panics if the provided value does not convert to JSON.
func NewFromBinary ¶
NewFromBinary reads a JSON snapshot.
func UnionObjects ¶
type JsonPatchSpec ¶
type JsonPatchSpec []map[string]interface{}
type JsonPatchTestFailed ¶
type JsonPatchTestFailed struct {
// contains filtered or unexported fields
}
func (JsonPatchTestFailed) Error ¶
func (e JsonPatchTestFailed) Error() string
type Object ¶
type Object interface {
Json
Names() []string
Set(name string, value Json) (Object, bool)
Value(name string) Json
Remove(name string) Object
Serialize(cache *encodingCache, buffer *bytes.Buffer, base int32) (int32, error)
Union(other Json) Json
Iterable
// contains filtered or unexported methods
}
Object represents JSON object.
func Debug ¶
func Debug(c Collections) Object
func NewObjectMapCompact ¶
type Object2 ¶
type Object2 interface {
Json
Insert(k, v Json) Object2
Get(k Json) (Json, bool)
Iter(iter func(key, value Json) (bool, error)) error
Iter2(iter func(key, value interface{}) (bool, error)) error
Equal(other Object2) bool
Diff(other Object2) Object2
Len() int
Hash() uint64
AST() ast.Value
Union(other Object2) Object2
// contains filtered or unexported methods
}
func NewObject2 ¶
type ObjectBinary ¶
type ObjectBinary struct {
// contains filtered or unexported fields
}
func (ObjectBinary) AST ¶
func (o ObjectBinary) AST() ast.Value
func (ObjectBinary) Clone ¶
func (o ObjectBinary) Clone(bool) File
func (ObjectBinary) Compare ¶
func (o ObjectBinary) Compare(other Json) int
func (ObjectBinary) Contents ¶
func (o ObjectBinary) Contents() interface{}
func (ObjectBinary) Iterate ¶
func (o ObjectBinary) Iterate(i int) Json
func (ObjectBinary) JSON ¶
func (o ObjectBinary) JSON() interface{}
func (ObjectBinary) Len ¶
func (o ObjectBinary) Len() int
func (ObjectBinary) Names ¶
func (o ObjectBinary) Names() []string
func (ObjectBinary) NamesIndex ¶
func (o ObjectBinary) NamesIndex(i int) string
func (ObjectBinary) Remove ¶
func (o ObjectBinary) Remove(name string) Object
func (ObjectBinary) RemoveIdx ¶
func (o ObjectBinary) RemoveIdx(i int) Json
func (ObjectBinary) String ¶
func (o ObjectBinary) String() string
func (ObjectBinary) Union ¶
func (o ObjectBinary) Union(other Json) Json
func (ObjectBinary) Value ¶
func (o ObjectBinary) Value(name string) Json
type ObjectMap ¶
type ObjectMap struct {
// contains filtered or unexported fields
}
type ObjectMapCompact ¶
type ObjectMapCompact[T indexable] struct {
// contains filtered or unexported fields
}
ObjectMapCompact is a compact implementation of the object map for objects with at most 32 keys.
func (*ObjectMapCompact[T]) AST ¶
func (o *ObjectMapCompact[T]) AST() ast.Value
func (*ObjectMapCompact[T]) Clone ¶
func (o *ObjectMapCompact[T]) Clone(deepCopy bool) File
func (*ObjectMapCompact[T]) Compare ¶
func (o *ObjectMapCompact[T]) Compare(other Json) int
func (*ObjectMapCompact[T]) Contents ¶
func (o *ObjectMapCompact[T]) Contents() interface{}
func (*ObjectMapCompact[T]) Extract ¶
func (o *ObjectMapCompact[T]) Extract(ptr string) (Json, error)
func (*ObjectMapCompact[T]) Iterate ¶
func (o *ObjectMapCompact[T]) Iterate(i int) Json
func (*ObjectMapCompact[T]) JSON ¶
func (o *ObjectMapCompact[T]) JSON() interface{}
func (*ObjectMapCompact[T]) Len ¶
func (o *ObjectMapCompact[T]) Len() int
func (*ObjectMapCompact[T]) Names ¶
func (o *ObjectMapCompact[T]) Names() []string
func (*ObjectMapCompact[T]) Remove ¶
func (o *ObjectMapCompact[T]) Remove(name string) Object
func (*ObjectMapCompact[T]) RemoveIdx ¶
func (o *ObjectMapCompact[T]) RemoveIdx(i int) Json
func (*ObjectMapCompact[T]) Set ¶
func (o *ObjectMapCompact[T]) Set(name string, value Json) (Object, bool)
func (*ObjectMapCompact[T]) String ¶
func (o *ObjectMapCompact[T]) String() string
func (*ObjectMapCompact[T]) Union ¶
func (o *ObjectMapCompact[T]) Union(other Json) Json
func (*ObjectMapCompact[T]) Value ¶
func (o *ObjectMapCompact[T]) Value(name string) Json
type ObjectMapCompactStrings ¶
type ObjectMapCompactStrings[T indexableStrings] struct {
// contains filtered or unexported fields
}
ObjectMapCompact is a compact implementation of the object map for objects with at most 32 String values.
func (*ObjectMapCompactStrings[T]) AST ¶
func (o *ObjectMapCompactStrings[T]) AST() ast.Value
func (*ObjectMapCompactStrings[T]) Clone ¶
func (o *ObjectMapCompactStrings[T]) Clone(bool) File
func (*ObjectMapCompactStrings[T]) Compare ¶
func (o *ObjectMapCompactStrings[T]) Compare(other Json) int
func (*ObjectMapCompactStrings[T]) Contents ¶
func (o *ObjectMapCompactStrings[T]) Contents() interface{}
func (*ObjectMapCompactStrings[T]) Extract ¶
func (o *ObjectMapCompactStrings[T]) Extract(ptr string) (Json, error)
func (*ObjectMapCompactStrings[T]) Iterate ¶
func (o *ObjectMapCompactStrings[T]) Iterate(i int) Json
func (*ObjectMapCompactStrings[T]) JSON ¶
func (o *ObjectMapCompactStrings[T]) JSON() interface{}
func (*ObjectMapCompactStrings[T]) Len ¶
func (o *ObjectMapCompactStrings[T]) Len() int
func (*ObjectMapCompactStrings[T]) Names ¶
func (o *ObjectMapCompactStrings[T]) Names() []string
func (*ObjectMapCompactStrings[T]) Remove ¶
func (o *ObjectMapCompactStrings[T]) Remove(name string) Object
func (*ObjectMapCompactStrings[T]) RemoveIdx ¶
func (o *ObjectMapCompactStrings[T]) RemoveIdx(i int) Json
func (*ObjectMapCompactStrings[T]) Set ¶
func (o *ObjectMapCompactStrings[T]) Set(name string, value Json) (Object, bool)
func (*ObjectMapCompactStrings[T]) SetIdx ¶
func (o *ObjectMapCompactStrings[T]) SetIdx(i int, j File) Json
func (*ObjectMapCompactStrings[T]) String ¶
func (o *ObjectMapCompactStrings[T]) String() string
func (*ObjectMapCompactStrings[T]) Union ¶
func (o *ObjectMapCompactStrings[T]) Union(other Json) Json
func (*ObjectMapCompactStrings[T]) Value ¶
func (o *ObjectMapCompactStrings[T]) Value(name string) Json
type Op ¶
type Op struct {
Value Json `json:"value,omitempty"`
Op PatchOp `json:"op"`
Path string `json:"path"`
From string `json:"from"` // Note, only marshaled if operation is either copy or move.
// contains filtered or unexported fields
}
func (Op) MarshalJSON ¶
type Patch ¶
type Patch []Op
func NewPatch ¶
func NewPatch(spec JsonPatchSpec) (Patch, error)
func (*Patch) UnmarshalJSON ¶
type Resource ¶
type Resource interface {
// Name returns the full name.
Name() string
// Kind returns Invalid if the resource does not exist, otherwise Unstructured (for a binary resource), JSON (for a JSON resource), and Directory for directory.
Kind() Kind
// Blob returns resource meta data for a particular resource. Provided name is local and scoped to the directory. Returns nil if no resource matches the name.
Resource(name string) Resource
// Resources returns all resources under a directory (not recursively, though). Will panic if the name does not point to a directory resource.
Resources() []Resource
// File returns a file object. It's callers responsibility to determine the type.
File() File
// Blob returns a binary resource. Will panic if the resource is not of binary type.
Blob() Blob
// Collection returns a JSON collection resource. Will panic if the resource is not of JSON type.
JSON() Json
// Meta returns a meta value for the key, and true if it exists.
Meta(key string) (string, bool)
// Walk executes a depth-first search over the resource, stopping the recursion to a particular node if the callback returns false but not the entire walk.
Walk(callback func(Resource) bool)
}
Resource captures the meta data available for a resource. It is limited to type information for now.
type Set ¶
type Set interface {
Json
Add(v Json) Set
Get(v Json) (Json, bool)
Iter(iter func(v Json) (bool, error)) (bool, error)
Iter2(iter func(v, vv interface{}) (bool, error)) (bool, error)
Equal(other Set) bool
Len() int
Hash() uint64
AST() ast.Value
MergeWith(other Set) Set
// contains filtered or unexported methods
}
type WritableCollections ¶
type WritableCollections interface {
// Blob returns resource meta data for a particular resource. Returns nil if no resource matches the name.
Resource(name string) Resource
// WriteBlob replaces the contents of a
WriteBlob(name string, blob Blob)
// WriteJSON
WriteJSON(name string, j Json)
// PatchJSON applies a patch to a JSON resource.
PatchJSON(name string, patch Patch) (bool, error)
// WriteDirectory
WriteDirectory(name string)
// Writes a meta key-value pair for a resource, returning if successful. Note, the resource has to exist this to take effect.
WriteMeta(name string, key string, value string) bool
// Prepare prepares the collection for log append. Any changes to the writable collection after this invocation are not reflected to the returned collections.
Prepare(timestamp time.Time) Collections
}
WritableCollections is updateable logical snapshot.
func NewCollections ¶
func NewCollections() WritableCollections
NewCollections translates a Go native collection of collections to the binary snapshot.