Menu

#40 make types in YAML optional?

open
nobody
None
5
2008-09-11
2008-09-11
No

public class SomeClass
{
public String name;
public int code;
public SomeOtherClass other;
}

public class SomeOtherClass
{
public String desc;
public int id;
}

JYaml serializes instances of SomeClass as something like this:

name: Foobar
code: 42
other: !SomeOtherClass
desc: Baz
id: 69

Is there a way to avoid this? My output is littered with this and I can't think of a reason why it needs it. Since it knows that "other" is of type "SomeOtherClass" via the class definition, couldn't it just TRY to bind the child nodes and not require the "!"? When I've removed it and deserialized, it simply ignores the data.

Discussion


Log in to post a comment.