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
if field is unexported, the field names will be empty slice. field names are used to decode or encode one go field from multiple json field. if is empty, meaning it is not present in json.
I am wondering whether unexported field need to be support if using the private field extension?
I thought extra.SupportPrivateFields() meant that the export of private fields were fully supported. Still don't get the idea why the rename of private fields are designed to be forbidden, which means lower-camel-case style is now a unpleasant compulsion for all exported JSON data of my program.
zhenzou
pushed a commit
to zhenzou/jsoniter
that referenced
this issue
Feb 2, 2022
Failed to support private fields when renaming.
`package main
import (
"fmt"
)
func main() {
extra.SupportPrivateFields()
type TestObject struct {
field string
json:"myfield"
}
obj := TestObject{}
jsoniter.UnmarshalFromString(
{"myfield":"Hello"}
, &obj)fmt.Println(obj.field) // Output empty string instead of "Hello"
}`
The text was updated successfully, but these errors were encountered: