Documentation ¶
Overview ¶
Package unstructured provides ways of manipulating unstructured data such as JSON or YAML
Index ¶
- Constants
- type Data
- func (j Data) BoolValue() (bool, error)
- func (j Data) F(key string) Data
- func (j Data) FindElem(match ElementMatcher) (Data, bool)
- func (j Data) GetByPointer(p string) (data Data, err error)
- func (j Data) HasKey(key string) bool
- func (j Data) HasPointer(p string) (bool, error)
- func (j Data) IsBool() bool
- func (j Data) IsList() bool
- func (j Data) IsNull() bool
- func (j Data) IsNum() bool
- func (j Data) IsOb() bool
- func (j Data) IsOfType(typ string) bool
- func (j Data) IsString() bool
- func (j Data) Keys() ([]string, error)
- func (j Data) ListValue() ([]Data, error)
- func (j Data) NumValue() (float64, error)
- func (j Data) ObValue() (map[string]interface{}, error)
- func (j Data) RawValue() interface{}
- func (j Data) SetElem(index int, value interface{}) error
- func (j Data) SetField(fieldName string, val interface{}) error
- func (j Data) StringValue() (string, error)
- func (j Data) UnsafeBoolValue() bool
- func (j Data) UnsafeGetField(key string) Data
- func (j Data) UnsafeListValue() (list []Data)
- func (j Data) UnsafeNumValue() float64
- func (j Data) UnsafeObValue() map[string]interface{}
- func (j Data) UnsafeStringValue() string
- type ElementMatcher
Constants ¶
const ( DataString = "string" DataNum = "number" DataOb = "object" DataList = "list" DataNull = "null" DataBool = "bool" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Data ¶
type Data struct {
// contains filtered or unexported fields
}
Data represents some unstructured data
func ParseJSON ¶
ParseJSON unmarshals json from an input string. Use this for generating a Data struct, whose contents you can examine using the following functions.
func ParseYAML ¶
ParseYAML unmarshals yaml from an input string. Use this for generating a Data struct, whose contents you can examine using the following functions.
func (Data) BoolValue ¶
BoolValue returns the golang bool representation of the bool represented by this Data struct. If the Data struct does not represent a bool, this method returns an error.
func (Data) FindElem ¶
func (j Data) FindElem(match ElementMatcher) (Data, bool)
FindElem finds an element in a list, using a provided matcher
func (Data) GetByPointer ¶
GetByPointer returns a Data struct containing the contents of the original data at the given pointer address `p`. For more information on json pointers, see https://tools.ietf.org/html/rfc6901
func (Data) HasKey ¶
HasKey returns true iff the object represented by this Data struct contains `key`
Note: this will panic if the data represented by this Data struct is not an object. If in doubt, check with `IsOb()`
func (Data) HasPointer ¶
HasPointer returns true iff the object represented by this Data struct contains the pointer `p`
For more information on json pointers, see https://tools.ietf.org/html/rfc6901
func (Data) IsOb ¶
IsOb returns true iff the data represented by this Data struct is an object or map.
func (Data) IsOfType ¶
IsOfType returns true iff the Data struct represents data of type `typ`. Valid values of `typ` are listed as constants above.
func (Data) IsString ¶
IsString returns true iff the data represented by this Data struct is a string.
func (Data) Keys ¶
Keys returns a list of the keys on this Data object.
If this is not a Data object, return an error
func (Data) ListValue ¶
ListValue returns a golang slice of Data structs representing the unstructured list represented by this Data struct. If the Data struct does not represent a list, this method returns an error.
func (Data) NumValue ¶
NumValue returns the golang float64 representation of the number represented by this Data struct. If the Data struct does not represent a number, this method returns an error.
func (Data) ObValue ¶
ObValue returns a golang map[string]interface{} represenation of the object represented by this Data struct. If the Data struct does not represent an object, this method returns an error
func (Data) RawValue ¶
func (j Data) RawValue() interface{}
RawValue returns the raw go value of the parsed data, without any type checking
func (Data) SetElem ¶
SetElem sets the element at a given index in this Data list to the given value. If this Data object does not represent a list, return an error
func (Data) SetField ¶
SetField updates the field `fieldName` of this Data object. If the field `fieldName` does not exist on this object, create it.
If this Data does not represent an object, return an error.
func (Data) StringValue ¶
StringValue returns the golang string representation of the string represented by this Data struct. If the Data struct does not represent a string, this method returns an error.
func (Data) UnsafeBoolValue ¶
UnsafeBoolValue returns the golang bool representation of the bool represented by this Data struct. If the Data struct does not represent a bool, this method panics. If in doubt, check with `IsBool()`
func (Data) UnsafeGetField ¶
UnsafeGetField returns a Data struct containing the contents of the original data at the given `key`. If this method name feels too long, use `F(key)`.
Note: this function panics if the given `key` does not exist. If in doubt, check with `HasKey()`.
func (Data) UnsafeListValue ¶
UnsafeListValue returns a golang slice of Data structs representing the unstructured list represented by this Data struct. If the Data struct does not represent a list, this method panics. If in doubt, check with `IsList()`
func (Data) UnsafeNumValue ¶
UnsafeNumValue returns the golang float64 representation of the number represented by this Data struct. If the Data struct does not represent a number, this method panics. If in doubt, check with `IsNum()`
func (Data) UnsafeObValue ¶
UnsafeObValue returns a golang map[string]interface{} represenation of the object represented by this Data struct. If the Data struct does not represent an object, this method panics. If in doubt, check with `IsOb()`
func (Data) UnsafeStringValue ¶
UnsafeStringValue returns the golang string representation of the string represented by this Data struct. If the Data struct does not represent a string, this method panics. If in doubt, check with `IsString()`
type ElementMatcher ¶
An ElementMatcher can be used with FindElem to find an element in an unstructured list.
Directories ¶
Path | Synopsis |
---|---|
Package gunstructured provides gomega matchers for using unstructured with the ginkgo and gomega testing libraries:
|
Package gunstructured provides gomega matchers for using unstructured with the ginkgo and gomega testing libraries: |