Deserialization of JSON and XML fail [UPDATED]

UPDATE: I tried binary serialization/deserialization and it works nicelly the problem with XML and JSON remains.

hello, recently I was in need of storing objects (derived from classes) as a Spread to xml and/or json files. I didnt try to store them as binary yet cause I was in need to have human readable code.
Although, the thing is that when I am storing my data everything works both for serialization and deserialization as long as I keep running my patch, but as soon as I close gamma or my main patch and reopen them again the desirialization fails with this message:



Nevertheless, my class tree has all the appropriate pads (I guess) and I cant trace where the problem might be.

Could it be that the .NET runtime type makes it into the serialized JSON string? I think once that happens the library has troubles finding that type again - we’re emitting types on the fly. Our own serializer should behave better in that regard as it uses the VL type names.

Doing a quick test I saw that the JSON serializer comes with a omit header flag - by default that is set to true on our nodes and so no type information is serialized and it should behave fine. However that will only work if all the types in your tree are known at compile time. Should you use something like Spread<object> with different instances stored in the spread you’ll be out of luck and should consider using our serializer or build your own.

Having stable .NET type names would be a nice property to have in VL so issues like you describe wouldn’t come up in the first place. But to achieve that we’d need to get more strict on what names are allowed and how projects / assembly boundaries are defined.

Still it would be good if you could upload an example. Maybe there is a workaround I just don’t see right now.

1 Like

hello @Elias , I marked your answer as a solution after I tried the binary equivalent and it works as it should. So I guess that you are already aware of the situation and you are after it. Thanks a lot for your prompt answer.
I will work with your serialization method for now.

Regarding the example, I ll try to reproduce it, since the patch is quite messy and big to upload it here.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.