- Introduction
- Example
- Usage
- Array Operators
- Date Operators
- Number Operators
- String Operators
- Playground
This package implemented lots of operators to manipulate JSON values. Currently, only a few operators were implemented.
Given JSON:
{
"total": {
"$sum": [1, 2]
}
}
Here, '$sum' will compute the sum of the array '[1, 2]', so the result will be:
{
"total": 3
}
/*
// Register your own operators if you have any.
err := operator.RegisterOP("$sha512", myOP)
if err != nil {
return err
}
*/
// First, parse JSON bytes to JValue.
jv, err := jvalue.ParseJSON([]byte(...))
if err != nil {
return err
}
// Do the operation.
newV, err := operator.Do(jv)
if err != nil {
return err
}
raw, err := newV.Marshal()
fmt.Println(raw)