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

add feature: 当byte反序列化成object时,使用tag查找属性 #19

Closed
gaoxinge opened this issue Apr 27, 2019 · 1 comment
Closed

Comments

@gaoxinge
Copy link
Contributor

如果定义的struct的属性不是以大写的英文开头,比如:

type TestObjectStruct struct {
	_value int
}

func (*TestObjectStruct) JavaClassName() string {
	return "com.caucho.hessian.test.TestObject"
}

那么在反序列化的时候,可能会遇到值绑定不上属性的情形:

https://github.com/dubbogo/hessian2/blob/develop/object.go#L299-L301

所以是不是可以使用tag查找属性,然后把值绑定到属性上:

type TestObjectStruct struct {
	Value int `hessian:"_value"`
}

func (*TestObjectStruct) JavaClassName() string {
	return "com.caucho.hessian.test.TestObject"
}
@AlexStocks
Copy link
Contributor

That is a good idea. If there is a tag for a struct member, we enc/dec by its tag name firstly.

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

2 participants