aboutsummaryrefslogtreecommitdiff
path: root/src/ProtocolBuffers.Serialization/JsonFormatWriter.cs
diff options
context:
space:
mode:
authorcsharptest <roger@csharptest.net>2011-09-08 20:02:11 -0500
committerrogerk <devnull@localhost>2011-09-08 20:02:11 -0500
commitc2d2c1adaf447bbc80194d8bce6c4e0442a7f47a (patch)
treea00d169fff4221e3779cb48e0e4c6001a1d5f604 /src/ProtocolBuffers.Serialization/JsonFormatWriter.cs
parent8f0dcf3df1548a1eff0bed54a9b992f55b8f72d5 (diff)
downloadprotobuf-c2d2c1adaf447bbc80194d8bce6c4e0442a7f47a.tar.gz
protobuf-c2d2c1adaf447bbc80194d8bce6c4e0442a7f47a.tar.bz2
protobuf-c2d2c1adaf447bbc80194d8bce6c4e0442a7f47a.zip
first pass at adding required changes
Diffstat (limited to 'src/ProtocolBuffers.Serialization/JsonFormatWriter.cs')
-rw-r--r--src/ProtocolBuffers.Serialization/JsonFormatWriter.cs20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/ProtocolBuffers.Serialization/JsonFormatWriter.cs b/src/ProtocolBuffers.Serialization/JsonFormatWriter.cs
index d54507cc..12d180d8 100644
--- a/src/ProtocolBuffers.Serialization/JsonFormatWriter.cs
+++ b/src/ProtocolBuffers.Serialization/JsonFormatWriter.cs
@@ -445,13 +445,31 @@ namespace Google.ProtocolBuffers.Serialization
/// </summary>
public override void WriteMessage(IMessageLite message)
{
+ StartMessage();
+ message.WriteTo(this);
+ EndMessage();
+ }
+
+ /// <summary>
+ /// Used to write the root-message preamble, in json this is the left-curly brace '{'.
+ /// After this call you can call IMessageLite.MergeTo(...) and complete the message with
+ /// a call to EndMessage().
+ /// </summary>
+ public override void StartMessage()
+ {
if (_isArray)
{
Seperator();
}
WriteToOutput("{");
_counter.Add(0);
- message.WriteTo(this);
+ }
+
+ /// <summary>
+ /// Used to complete a root-message previously started with a call to StartMessage()
+ /// </summary>
+ public override void EndMessage()
+ {
_counter.RemoveAt(_counter.Count - 1);
WriteLine("}");
Flush();