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
我创建了一个包含jsoniter.RawMessage类型的结构体,如下
type Log struct { Env string `json:"env"` Extra jsoniter.RawMessage `json:"extra,omitempty"` }
然后实例化
log := Log{ Env: "jfdk", }
我并没有给Extra赋值,此时它应该为空,我尝试将此对象解析成json字符串
logString, err := jsoniter.Marshal(log) fmt.Println(err) fmt.Println(string(logString))
此时程序没有打印错误,打印出解析后的字符床如下 "{"env":"jfdk","extra":}" 这明显不是一个符合json标准的字符串
然后我尝试将该字符串反解成结构体对象
err = jsoniter.Unmarshal(logString, relog) fmt.Println(err) fmt.Println(relog)
此时程序报错了
main.Log.Extra: Skip: do not know how to skip: 125, error found in #10 byte of ...|,"extra":}|..., bigger context ...|{"env":"jfdk","extra":}|...
所以,这是一个bug吗,还是我使用的姿势不对?
The text was updated successfully, but these errors were encountered:
5d789e5
fix json-iterator#291 omit empty was not handled properly for json ra…
28f6444
…w message
No branches or pull requests
我创建了一个包含jsoniter.RawMessage类型的结构体,如下
然后实例化
我并没有给Extra赋值,此时它应该为空,我尝试将此对象解析成json字符串
此时程序没有打印错误,打印出解析后的字符床如下
"{"env":"jfdk","extra":}"
这明显不是一个符合json标准的字符串
然后我尝试将该字符串反解成结构体对象
此时程序报错了
所以,这是一个bug吗,还是我使用的姿势不对?
The text was updated successfully, but these errors were encountered: