Specifically the `serialize` and `deserialize` fun...
# serialization
j
Specifically the
serialize
and
deserialize
functions. Note that you do need to write your own descriptor that further defines the fields for
type
and
data
.
p
thanks so much. Do you think the MirrorClass code would be needed in my case for the descriptor? Attempting to modify the deserialize fun for my needs, however the CompositeDecoder.READ_ALL when block is never reached.
j
No, it's not needed at all.
MirrorClass
just has some stuff that makes it a tad easier to define all the fields, but it is by no means necessary. READ_ALL doesn't necessarily ever occur, to my understanding - it depends on the particular format.
Note the
0 ->
and
1 ->
sections - they're for individual properties
p
it goes to the READ_DONE block and nothing else
p
In my case decodeElementIndex() returns -1 every time because the descriptor does not have a value for the key. The keys in the Jon are dynamic. Trying to find a way to handle that
p
have you seen any documentation on Decoder interface?
Seems like with the the discriminator must come first so the type is known. The api appears to only iterate sequentially over the data. Is that right?
j
Yes, that's correct. Discriminator must come first. The only way around that would be to deserialize the whole thing into a map, find the target type for deserializing, then make that map into the destination type.