Documentation ¶
Index ¶
- func ToJSON(params ValueMap) (string, error)
- func Truncate(s string, maxLength int) string
- type Filters
- type Operator
- type Sorter
- type Type
- type Value
- func (v Value) BoolVal() bool
- func (v Value) Equal(other Value) (bool, error)
- func (v Value) FloatVal() float64
- func (v Value) GreaterOrEqual(other Value) (bool, error)
- func (v Value) GreaterThan(other Value) (bool, error)
- func (v Value) IntVal() int64
- func (v Value) IsNone() bool
- func (v Value) LessOrEqual(other Value) (bool, error)
- func (v Value) LessThan(other Value) (bool, error)
- func (v Value) MarshalJSON() ([]byte, error)
- func (v Value) NotEqual(other Value) (bool, error)
- func (v Value) ObjectVal() interface{}
- func (v Value) PythonString() string
- func (v Value) ShortString(maxLength int, precision int) string
- func (v Value) String() string
- func (v Value) StringVal() string
- func (v Value) Type() Type
- func (v *Value) UnmarshalJSON(data []byte) error
- type ValueGetter
- type ValueMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Sorter ¶
func (*Sorter) LessThan ¶
func (s *Sorter) LessThan(x ValueGetter, y ValueGetter) bool
type Type ¶
type Type string
const ( TypeInt Type = "int" TypeFloat Type = "float" TypeString Type = "string" TypeBool Type = "bool" TypeObject Type = "object" TypeNone Type = "none" // hack in nan, +inf and -inf since json doesn't support // them natively. JsonNaN = `"[NaN]"` JsonPositiveInfinity = `"[+Infinity]"` JsonNegativeInfinity = `"[-Infinity]"` )
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
func ParseFromString ¶
ParseFromString attempts to turn a string passed to a filter into a value. They aren't valid JSON because they're provided by a human (strings might not have quotes, etc).
func (Value) MarshalJSON ¶
func (Value) PythonString ¶
func (Value) ShortString ¶
ShortString returns a shorter version of the string, useful for displaying in the user interface when there isn't much space
Small floats will be truncated to precision decimal points. Big floats will be truncated to maxLength Strings will be truncated to maxLength. Everything else is just default.
TODO: some interesting stuff could be done with color here (e.g. "..." and "none" could be dimmed) so maybe this should be lifted out into a generic shortener in the console package.
func (*Value) UnmarshalJSON ¶
Note that unlike everywhere else, this function uses a pointer for v. This is because this function needs to modify the struct in place.