Skip to content
HuJSON: JSON for Humans (comments and trailing commas)
Go
Branch: master
Clone or download

Latest commit

Latest commit 5098e56 Sep 30, 2019

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
testdata hujson: initial import of Go 1.13 json package Sep 29, 2019
LICENSE LICENSE: add Sep 30, 2019
README.md README.md: initial commit Sep 30, 2019
bench_test.go hujson: initial import of Go 1.13 json package Sep 29, 2019
decode.go hujson: support single and multi-line comments Sep 29, 2019
decode_test.go hujson: initial import of Go 1.13 json package Sep 29, 2019
encode.go hujson: initial import of Go 1.13 json package Sep 29, 2019
encode_test.go
example_marshaling_test.go hujson: initial import of Go 1.13 json package Sep 29, 2019
example_test.go hujson: initial import of Go 1.13 json package Sep 29, 2019
example_text_marshaling_test.go hujson: initial import of Go 1.13 json package Sep 29, 2019
fold.go hujson: initial import of Go 1.13 json package Sep 29, 2019
fold_test.go hujson: initial import of Go 1.13 json package Sep 29, 2019
fuzz.go
go.mod hujson: initial commit Sep 29, 2019
hujson_decode_test.go hujson: support trailing commas Sep 29, 2019
indent.go hujson: support single and multi-line comments Sep 29, 2019
number_test.go hujson: initial import of Go 1.13 json package Sep 29, 2019
scanner.go hujson: support trailing commas Sep 29, 2019
scanner_test.go
stream.go hujson: support single and multi-line comments Sep 29, 2019
stream_test.go hujson: initial import of Go 1.13 json package Sep 29, 2019
tables.go
tagkey_test.go
tags.go hujson: initial import of Go 1.13 json package Sep 29, 2019
tags_test.go hujson: initial import of Go 1.13 json package Sep 29, 2019

README.md

HuJSON - Human JSON

The HuJSON decoder is a JSON decoder that also allows

  • comments, both /* ... */ and // to end of line
  • trailing commas on arrays and object members

It is a soft fork of the Go standard library encoding/json package. The plan is to merge in all changes from each Go release.

Currently HuJSON is based on Go 1.13.

Grammar

The changes to the JSON grammar are:

--- grammar.json
+++ grammar.hujson
@@ -1,13 +1,31 @@
 members
 	member
+	member ',' ws
 	member ',' members
 
 elements
 	element
+	element ',' ws
 	element ',' elements
 
+comments
+	"*/"
+	comment comments
+
+comment
+	'0000' . '10FFFF'
+
+linecomments
+	'\n'
+	linecomment
+
+linecomment
+	'0000' . '10FFFF' - '\n'
+
 ws
 	""
+	"/*" comments
+	"//" linecomments
 	'0020' ws
 	'000A' ws
 	'000D' ws
You can’t perform that action at this time.