You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Is it possible to deserialize a custom class from MessagePackObject #90
I am asking because I have a basic "rpc-like" messaging system, and I want to serialize an object from one of the parameters. So it looks like this:
{
"command": "create_user",
"parameters": {
"hash": 1234,
"user": {"user_name": "test_user", "password": "1234", "email": "test@test.com"}
}
}
So I need to receive a command first, check what it is and than deserialize a User object from the second parameter. Is there any "right" way to to it?
@yfakariya that's what I have right now.
And that's a problem I described in my first message - after taking MessagePackObject from the Parameters dictionary, I can't deserialize it into the class/object.
Instead, I have to write
Activity
yfakariya commentedon Jul 5, 2015
No, there are no
Unpackers to support it. But it sounds good.leonidumanskiy commentedon Jul 6, 2015
I am asking because I have a basic "rpc-like" messaging system, and I want to serialize an object from one of the parameters. So it looks like this:
{
"command": "create_user",
"parameters": {
"hash": 1234,
"user": {"user_name": "test_user", "password": "1234", "email": "test@test.com"}
}
}
So I need to receive a command first, check what it is and than deserialize a User object from the second parameter. Is there any "right" way to to it?
yfakariya commentedon Aug 16, 2015
Sorry I missed the additional question. I recommend you to implement following class:
and then, you check
Parametersand use. I agree that it is not convinient at all, so I'll addObjectUnpackerlike API in future release.leonidumanskiy commentedon Aug 16, 2015
@yfakariya that's what I have right now.
And that's a problem I described in my first message - after taking MessagePackObject from the Parameters dictionary, I can't deserialize it into the class/object.
Instead, I have to write
which is really annoying. Especially when my class has about 20 different properties :)
Hope to see an update asap!
TSnake41 commentedon Aug 17, 2015
Hi, I've found a solution if you know the type
You got an object with the right type.
yfakariya commentedon Sep 23, 2016
I will add helper extension methods in next release. It will be based on @TSnake41's idea. Thank you.
Add ToMessagePackObject FromMessagePackObject. #90
yfakariya commentedon Sep 26, 2017
This was implemented in 0.9.