...

Source file src/github.com/TylerBrock/colorjson/examples/simple.go

Documentation: github.com/TylerBrock/colorjson/examples

     1  package main
     2  
     3  import (
     4      "fmt"
     5      "github.com/TylerBrock/colorjson"
     6      "encoding/json"
     7  )
     8  
     9  func main() {
    10      str := `{
    11        "str": "foo",
    12        "num": 100,
    13        "bool": false,
    14        "null": null,
    15        "array": ["foo", "bar", "baz"],
    16        "obj": { "a": 1, "b": 2 }
    17      }`
    18  
    19      var obj map[string]interface{}
    20      json.Unmarshal([]byte(str), &obj)
    21  
    22      // Marshall the Colorized JSON
    23      s, _ := colorjson.Marshal(obj)
    24      fmt.Println(string(s))
    25  }
    26  
    27  

View as plain text