We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
package main import ( "encoding/json" "fmt" ) func main() { // jsonDeal([]byte(`{"name":"xiaoming","course":["1111","2222"]}`)) // jsonDeal([]byte(`{"name":"xiaoming","course":["1111"]}`)) jsonDeal([]byte(`{"name":"xiaoming","course":[null]}`)) // jsonDeal([]byte(`{"name":"xiaoming","course":[]}`)) // jsonDeal([]byte(`{"name":"xiaoming","course":null}`)) } type User struct { Name string `json:"name"` Course []string `json:"course"` } func jsonDeal(data []byte) { var oneUser User if err := json.Unmarshal(data, &oneUser); err != nil { panic(err) return } fmt.Println("==============") fmt.Println("oridata:", string(data)) fmt.Println("json result:", oneUser) fmt.Println("course num:", len(oneUser.Course)) return }
I think len(oneUser.Course) should be 0,but now it is 1.
The text was updated successfully, but these errors were encountered:
I don't see why you think it is a bug. IMO, a [null] array is not the same as a [] array ...
Sorry, something went wrong.
@dspezia ,I understand, [null]string equals [""]string. thanks.
No branches or pull requests
I think len(oneUser.Course) should be 0,but now it is 1.
The text was updated successfully, but these errors were encountered: