json5b

command module
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2023 License: BSD-2-Clause, MIT Imports: 6 Imported by: 0

README

json5 implemented by golang

Forked version of yosuke-furukawa/json5, uses json5 tag instead of default json tag.

JSON5 is Yet another JSON.

INSTALL

$ brew tap yosuke-furukawa/json5 # original one
$ brew install json5

HOW TO USE

$ 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

$ go get github.com/kokizzu/json5b

example

package main

import (
	"encoding/json"
	"fmt"
	"github.com/kokizzu/json5b/encoding/json5b"
	"os"
)

func main() {
	var data interface{}
	dec := json5b.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"
#}

TODO

  • block comment
  • multiline string
  • hexadecimal notation

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
encoding
json5b
Package json implements encoding and decoding of JSON objects as defined in RFC 4627.
Package json implements encoding and decoding of JSON objects as defined in RFC 4627.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL