serialize Document.scala by myself