-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
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
解析[]byte出现乱码(同时并不希望自动base64decode) #244
Comments
以上内容,解析的结果是: |
当前 encoding/json 的行为是
json-iterator 的默认行为必须和 encoding/json 保持兼容。但是我等会添加一个扩展,支持把 []byte 解读为 string 来处理,对非 utf8 用 |
请问是对“非utf8”用\x转义,还是对“utf8”用\x转义。但从实验结果上来看,正常的utf8编码也被\x转义了。 是我的理解有问题吗? |
…ty, while the output is valid json, but it can not be decoded by other json codec, as \x01 is decoded as \x01 by them, which is not original input
type Message struct {
URL string
json:"url"
Body []byte
json:"body"
Strategy []int
json:"strategy"
Method string
json:"method"
// Headers []Header
json:"headers"
Handler string
json:"handler,omitempty"
Referer string
json:"referer,omitempty"
Headers map[string]string
json:"headers"
}
.....
body := []byte(
{"url":"abc.com","method":"PUT","body":"asdasdfsdfsfsfasfd==","strategy":[10,11,12,13,14,15,16,17,18,19,20],"headers":[],"referer":null,"handler":"f331db77be59f18eab9ada6924e04a32"}
)......
结果是:j�Z���u����}
如果
body := []byte(
{"url":"abc.com","method":"PUT","body":"eyJ1c2VybmFtZSI6InRlc3RlciIsInBhc3N3b3JkIjoiMTIzNDU2In0=","strategy":[10,11,12,13,14,15,16,17,18,19,20],"headers":[],"referer":null,"handler":"f331db77be59f18eab9ada6924e04a32"}
)则结果为:{"username":"tester","password":"123456"}
但是我并不想jsoniter帮我自动解码呀。
另外如果body的内容是比较长的base64内容,这返回:
main.Message.Method: Body: decode base64: illegal base64 data at input byte 230, error found in #10 byte of ...|wIn19fX0=","method":|..., bigger context ...|0aW9uIjoiMC4wMCIsInJldmVudWUiOiIyODAwLjAwIn19fX0=","method":"POST","strategy":[30,300],"headers":{"C|...
这个错误。
The text was updated successfully, but these errors were encountered: