Skip to content

Instantly share code, notes, and snippets.

@hernad
Created May 16, 2011 16:18
Show Gist options
  • Save hernad/974759 to your computer and use it in GitHub Desktop.
Save hernad/974759 to your computer and use it in GitHub Desktop.
Serializable Facet
// http://fantom.org/doc/docIntro/Tour.html
@Serializable
class Person
{
Str name := ""
Int age := 0
Person[]? children
}
class Main {
Void main()
{
// built up tree of objects in code (or from file)
homer := Person
{
name = "Homer Simpson"
age = 39
children =
[
Person { name = "Bart"; age = 7 },
Person { name = "Lisa"; age = 5 },
Person { name = "Maggie"; age = 1 }
]
}
// dump serialized structure to console
Env.cur.out.writeObj(homer, ["indent":2])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment