commit | 174fdd4c3323f6e4aa75094efc88a986f635d76d | [log] [tgz] |
---|---|---|
author | Yosuke Furukawa <[email protected]> | Mon Dec 07 04:58:12 2020 |
committer | GitHub <[email protected]> | Mon Dec 07 04:58:12 2020 |
tree | 5c73566b371d9b2b49dd423e74a8a9c2ac272ee2 | |
parent | 1c306d9836a49e3cde1373beee47845bcce64793 [diff] | |
parent | 6134833a05bfeb91763873351dc404dd58321548 [diff] |
Merge pull request #13 from vearutop/json-unmarshaler Strip comment from nextValue to fix custom unmarshalers
JSON5 is Yet another JSON.
$ brew tap yosuke-furukawa/json5 $ brew install json5
$ json5 -c path/to/test.json5 # output stdout $ json5 -c path/to/test.json5 -o path/to/test.json # output path/to/test.json
$ go get github.com/yosuke-furukawa/json5
package main
import (
"encoding/json"
"fmt"
"github.com/yosuke-furukawa/json5/encoding/json5"
"os"
)
func main() {
var data interface{}
dec := json5.NewDecoder(os.Stdin)
err := dec.Decode(&data)
if err != nil {
fmt.Println(err)
}
b, err := json.MarshalIndent(data, "", " ")
if err != nil {
fmt.Println(err)
}
fmt.Println(string(b))
}
// This is json5 demo // json5 can write comment in your json { key : "Key does not need double quote", // json specific "of" : "course we can use json as json5", trailing : "trailing comma is ok", }
$ json5 -c example.json5 # output #{ # "key": "Key does not need double quote", # "of": "course we can use json as json5", # "trailing": "trailing comma is ok" #}