Skip to main content

Posts

Showing posts with the label serialization

Deserialize nested class using yamlbeans

I'm using yamlbeans to deserialize yaml files into Java objects. This works fine as long as I only have one class. The problem is when I want to nest a field, I am forced to specify the nested class in the yaml description. Single class example: Java: public class MessageField { public String name; public String type; public int length; public String comment; } yaml: name: field1 type: int length: 4 comment: first field --- name: field2 type: string length: 16 comment: second field --- Multiple classes (requires !com.mylib.VariableField in yaml file) Java: public class MessageField { public String name; public String type; public int length; public String comment; public List<VariableField> variableFields; } public class VariableField extends MessageField{ public int id; } yaml: name: field3 type: short length: 2 comment: variableFields: - !com.mylib.VariableField id: 1 name: nestedField 1 type: string le

retrieve serialized java.util.Arraylist in asp.net client (SUID doesn"t match)

I am trying to send persisted objects from a java webservice to the ASP.Net client. Both sides have the object-classes, with the same SerialUID's. Classes without (Array)Lists pose no problem, but when I want to send objects including ArrayLists, the expected SUID is incorrect: [java.io.InvalidClassException] = {"the class does not match the class of the persisted object for cl = java.util.ArrayList : __SUID = 8683452581122892189, getSUID(cl) = 9195509126275115639"} Serialization is implemented using binary formatting, not XML because with XML we have circular references between the persisted objects. Using J# at client side, by expecting a java.util.ArrayList instead of an IList or a System.collections.ArrayList doesn't change anything. Any help would be greatly appreciated!