Skip to content

Instantly share code, notes, and snippets.

@KensoDev
Created August 8, 2017 03:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KensoDev/be00801e9af795dfd0888442096a5601 to your computer and use it in GitHub Desktop.
Save KensoDev/be00801e9af795dfd0888442096a5601 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"io/ioutil"
"os"
"github.com/Jeffail/gabs"
)
func main() {
bytes, err := ioutil.ReadAll(os.Stdin)
if err != nil {
panic(err)
}
jsonParsed, err := gabs.ParseJSON(bytes)
value, ok := jsonParsed.Path("_source.event_type").Data().(string)
fmt.Println(value)
fmt.Println(ok)
jsonParsed.Set("something", "fake_value_kensodev")
jsonOutput := jsonParsed.String()
fmt.Println(jsonOutput)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment