Fix bug with unquoting null from JSON-encoded HCL
Fixes hashicorp/terraform#6774.
This commit is contained in:
parent
aa7699b7b6
commit
39143f46f8
@ -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,
|
||||
|
@ -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))
|
||||
|
7
test-fixtures/null_strings.json
Normal file
7
test-fixtures/null_strings.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"module": {
|
||||
"app": {
|
||||
"foo": null
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user