diff --git a/.travis.yml b/.travis.yml index f918f8d..b721422 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,4 +2,6 @@ language: go go: - 1.7 + - 1.8 + - 1.9 - tip diff --git a/identifier.go b/identifier.go index a837d7f..14f6eaf 100644 --- a/identifier.go +++ b/identifier.go @@ -49,7 +49,7 @@ var reservedWords = map[string]bool{ // a key with spaces -> false // 1startsWithANumber -> false func validIdentifier(s string) bool { - if reservedWords[s] { + if reservedWords[s] || s == "" { return false } diff --git a/identifier_test.go b/identifier_test.go index 8ec3774..82df524 100644 --- a/identifier_test.go +++ b/identifier_test.go @@ -21,6 +21,9 @@ func TestValidIdentifier(t *testing.T) { {"true", false}, {"else", false}, {"null", false}, + + // Empty string + {"", false}, } for _, test := range tests { diff --git a/script/precommit b/script/precommit index fab77fa..a26884f 100755 --- a/script/precommit +++ b/script/precommit @@ -4,4 +4,3 @@ PROJDIR=$(cd `dirname $0`/.. && pwd) cd ${PROJDIR} ./script/test -./script/lint diff --git a/statements_test.go b/statements_test.go index 5192259..12137a3 100644 --- a/statements_test.go +++ b/statements_test.go @@ -29,7 +29,8 @@ func TestStatementsSimple(t *testing.T) { "foo": "bar" }, "else": 1, - "id": 66912849 + "id": 66912849, + "": 2 }`) ss, err := statementsFromJSON(bytes.NewReader(j), statement{{"json", typBare}}) @@ -52,6 +53,7 @@ func TestStatementsSimple(t *testing.T) { `json.anob.foo = "bar";`, `json["else"] = 1;`, `json.id = 66912849;`, + `json[""] = 2;`, }) t.Logf("Have: %#v", ss)