Moved JSON serialization to intermediate class so it can be used by external applications.

BUG=
R=amoser@google.com

Review URL: https://codereview.appspot.com/101390044