Skip to content
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

json string decode 数据有误 #272

Closed
SocketNet opened this issue Jul 13, 2021 · 5 comments
Closed

json string decode 数据有误 #272

SocketNet opened this issue Jul 13, 2021 · 5 comments

Comments

@SocketNet
Copy link

SocketNet commented Jul 13, 2021

Java 对象

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ImRequestMsgBody {
    private String url;
    private Map<String, Object> params;
}

转 JSON字符串后通过 Hessian2Output 序列化,得到以下数据

1;{"params":{"fromAccid":"23495382","msgType":100,"msgId":"148ef1b2-808d-48f2-b268-7a1018a27bdb","attach":"{\"accid\":\"23495382\",\"classRoomFlag\":50685,\"msgId\":\"599645021431398400\",\"msgType\":\"100\",\"nickname\":\"橙子������\"}","roomid":413256699},"url":"https://api.netease.im/nimserver/chatroom/sendMsg.action"}

Go 还原后得到以下数据


func stringHessianDecode(data []byte) (string, error) {
	decode := hessian.NewDecoder(data)
	res, err := decode.Decode()
	if err != nil {
		return "", err
	}
	return res.(string), nil
}

{"params":{"fromAccid":"23495382","msgType":100,"msgId":"148ef1b2-808d-48f2-b268-7a1018a27bdb","attach":"{\"accid\":\"23495382\",\"classRoomFlag\":50685,\"msgId\":\"599645021431398400\",\"msgType\":\"100\",\"nickname\":\"橙子������\"}","roomid":413256699},"url":"https://api.netease.im/nimserver/chatroom/sendMsg.acti

无法还原Java通过Hessian2Output Encode前的JsonString

@wongoo
Copy link
Contributor

wongoo commented Jul 13, 2021

@SocketNet 你的意思是反序列化后得到的字符串有丢失吗?

@SocketNet
Copy link
Author

是的,部分丢失。并不是所有字符串都有问题。昨天上线后10w的消息里至少1k条是有问题的。需要的话,这边可以提供更多数据

wongoo added a commit to wongoo/hessian2 that referenced this issue Jul 14, 2021
@wongoo
Copy link
Contributor

wongoo commented Jul 14, 2021

@SocketNet 加了单元测试是可以的,你看看是不是可以模拟出问题? #273

@SocketNet
Copy link
Author

👍好的,我今天找时间验证下

@wongoo
Copy link
Contributor

wongoo commented Aug 24, 2021

@SocketNet 有找到问题吗?

AlexStocks added a commit that referenced this issue Aug 24, 2021
zhaoyunxing92 pushed a commit that referenced this issue Sep 4, 2021
zhaoyunxing92 pushed a commit that referenced this issue Sep 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants