Fork from http://code.google.com/p/protobuf-java-format/
See http://bivas.github.io/protobuf-java-format/ for more information.
Provide serialization and de-serialization of different formats based on Google’s protobuf Message. Enables overriding the default (byte array) output to text based formats such as XML, JSON and HTML.
##Example For XML output, use XmlFormat
MessagesomeProto = SomeProto.getDefaultInstance();
XmlFormatxmlFormat = newXmlFormat();
StringasXml = xmlFormat.printToString(someProto);For XML input, use XmlFormat
Message.Builderbuilder = SomeProto.newBuilder();
StringasXml = _loadxmldocumentfromasource_;
XmlFormatxmlFormat = newXmlFormat();
xmlFormat.merge(asXml, builder);For Json output, use JsonFormat
MessagesomeProto = SomeProto.getDefaultInstance();
JsonFormatjsonFormat = newJsonFormat();
StringasJson = jsonFormat.printToString(someProto);For Json input, use JsonFormat
Message.Builderbuilder = SomeProto.newBuilder();
StringasJson = _loadjsondocumentfromasource_;
JsonFormatjsonFormat = newJsonFormat();
jsonFormat.merge(asJson, builder);For HTML output, use HtmlFormat
MessagesomeProto = SomeProto.getDefaultInstance();
HtmlFormathtmlFormat = newHtmlFormat();
StringasHtml = htmlFormat.printToString(someProto);