Documentation ¶
Index ¶
- Variables
- type Event
- func (e *Event) Delete(key string) (deleted *Value)
- func (e *Event) Get(key string) *Value
- func (e *Event) MarshalJSON() ([]byte, error)
- func (e *Event) Put(key string, val *Value) (old *Value, err error)
- func (e *Event) TryPut(key string, val *Value) (existing *Value, err error)
- func (e *Event) UnmarshalJSON(data []byte) error
- type Time
- type Value
- type ValueType
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrKeyExists = errors.New("key already exists") ErrTargetKeyNotObject = errors.New("target key is not an object") ErrEmptyKey = errors.New("key name is empty") )
View Source
var NullValue = &Value{Type: NullType}
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
Example ¶
e := New() e.Put("event.category", Array(String("network"), String("authentication"))) e.Put("event.type", Array(String("denied"))) e.Put("event.created", Timestamp(testTimeUnix)) e.Put("foo\\.bar", Integer(1)) data, err := json.MarshalIndent(e, "", " ") if err != nil { panic(err) } fmt.Println(string(data))
Output: { "event": { "category": [ "network", "authentication" ], "created": "2022-01-14T00:45:57.123456789Z", "type": [ "denied" ] }, "foo.bar": 1 }
func (*Event) Get ¶
Get returns the value associated to the given key. It returns nil if the key does not exist.
func (*Event) MarshalJSON ¶
func (*Event) Put ¶
Put puts a value into the map. If the key already exists then it will be overwritten. If the target value is not an object then ErrTargetKeyNotObject is returned.
func (*Event) TryPut ¶
TryPut puts a value into the map if the key does not exist. If the key already exists it will return the existing value and ErrKeyExists. If the target value is not an object then ErrTargetKeyNotObject is returned.
func (*Event) UnmarshalJSON ¶
Click to show internal directories.
Click to hide internal directories.