You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following program works differently between 0.3.1 and 0.4.1:
package main
import (
"log"
"reflect"
"github.com/BurntSushi/toml"
)
func main() {
blob := `
x = []
`
var d map[string]interface{}
if _, err := toml.Decode(blob, &d); err != nil {
log.Fatal(err)
}
x := d["x"]
log.Println(x, reflect.ValueOf(x).IsNil())
}
On 0.3.1,
[] false
On 0.4.1,
[] true
For my use case, this is a problem because I'm subsequently encoding the value into JSON and it writes x = null instead of the expected x = []. It also goes deeper than that, for instance x = [[]] would get JSONed as x = [null].
Is this an intended change? Do you think it would be possible/correct to restore the previous behaviour?
The text was updated successfully, but these errors were encountered:
It's not really an intentional change, as far as I can recall.
It's really the encoding/json behaviour that's problematic; it's a long-standing issue. I'll probably fix it eventually, but it might be a while. I'll review and merge PRs though.
dtcaciuc
added a commit
to dtcaciuc/toml
that referenced
this issue
Jan 12, 2022
The following program works differently between 0.3.1 and 0.4.1:
On 0.3.1,
On 0.4.1,
For my use case, this is a problem because I'm subsequently encoding the value into JSON and it writes
x = null
instead of the expectedx = []
. It also goes deeper than that, for instancex = [[]]
would get JSONed asx = [null]
.Is this an intended change? Do you think it would be possible/correct to restore the previous behaviour?
The text was updated successfully, but these errors were encountered: