Amazon interview question

Write code to serialize and then deserialize a tree.