commit | a3b86299204ff020cea4f942262bf15c7edcd440 | [log] [tgz] |
---|---|---|
author | yosuke-furukawa <yosuke.furukawa@gmail.com> | Wed Dec 03 06:26:03 2014 |
committer | yosuke-furukawa <yosuke.furukawa@gmail.com> | Wed Dec 03 06:26:03 2014 |
tree | da2729990e2c4c71326cc062ae0f13fcf0095328 | |
parent | d2837656373824b41fd342395fe4613ee62d656e [diff] |
Fix gojson5 to json5
JSON5 is Yet another JSON.
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" #}