Incorrect, @mratsim definitely put generic in there, meant, the type T that you
should make it variant or heterogeneous.
Also considering with your example about @[messageType, messageId, rpc_method,
arguments]
It should have a structure like this
type
MyHeterogeneousVals = ref object
case mgHeader:
`type`: int
case mgId:
id: uint64
case mgRpc:
`method`: string
case mgArray:
arr: seq[MyHeterogeneousVals]
# add any possible heterogeneous values
# you defined
Run
Many nimble package do like that, for example [nimongo
bson](https://github.com/SSPkrolik/nimongo) , just look the code and it's
precisely using object variant.
For serialization, you should definitely consider to use
[nesm](https://xomachine.gitlab.io/NESM/) , I haven't use it but I've seen the
example and it provides clean and precise way to serialize your object.