Fix bug with unquoting null from JSON-encoded HCL

Fixes hashicorp/terraform#6774.
This commit is contained in:
James Nugent 2016-06-20 19:53:10 +03:00
parent aa7699b7b6
commit 39143f46f8
3 changed files with 25 additions and 0 deletions

View File

@ -109,6 +109,19 @@ func TestDecode_interface(t *testing.T) {
false,
map[string]interface{}{"foo": "bar\nbaz"},
},
{
"null_strings.json",
false,
map[string]interface{}{
"module": []map[string]interface{}{
map[string]interface{}{
"app": []map[string]interface{}{
map[string]interface{}{"foo": ""},
},
},
},
},
},
{
"scientific.json",
false,

View File

@ -152,6 +152,11 @@ func (t Token) Value() interface{} {
f = strconv.Unquote
}
// This case occurs if json null is used
if t.Text == "" {
return ""
}
v, err := f(t.Text)
if err != nil {
panic(fmt.Sprintf("unquote %s err: %s", t.Text, err))

View File

@ -0,0 +1,7 @@
{
"module": {
"app": {
"foo": null
}
}
}