aboutsummaryrefslogtreecommitdiff
path: root/csharp/src/Google.Protobuf/MessageParser.cs
diff options
context:
space:
mode:
authorJon Skeet <skeet@pobox.com>2015-11-03 22:39:08 -0800
committerJon Skeet <skeet@pobox.com>2015-11-03 22:39:08 -0800
commitb6a32e909b1f58f157c19276af233e44627093f4 (patch)
treeba07d19ca93d4aa01bb4ce3131984447f53cdb4d /csharp/src/Google.Protobuf/MessageParser.cs
parent55ad57a235c009d0414aed1781072adda0c89137 (diff)
parentfb2488225fbd239f7880e3b493cbfd2f19da755b (diff)
downloadprotobuf-b6a32e909b1f58f157c19276af233e44627093f4.tar.gz
protobuf-b6a32e909b1f58f157c19276af233e44627093f4.tar.bz2
protobuf-b6a32e909b1f58f157c19276af233e44627093f4.zip
Merge pull request #923 from jskeet/json-parsing
Implement JSON parsing in C#.
Diffstat (limited to 'csharp/src/Google.Protobuf/MessageParser.cs')
-rw-r--r--csharp/src/Google.Protobuf/MessageParser.cs12
1 files changed, 12 insertions, 0 deletions
diff --git a/csharp/src/Google.Protobuf/MessageParser.cs b/csharp/src/Google.Protobuf/MessageParser.cs
index 6a6f1017..70c52ba6 100644
--- a/csharp/src/Google.Protobuf/MessageParser.cs
+++ b/csharp/src/Google.Protobuf/MessageParser.cs
@@ -142,5 +142,17 @@ namespace Google.Protobuf
message.MergeFrom(input);
return message;
}
+
+ /// <summary>
+ /// Parses a message from the given JSON.
+ /// </summary>
+ /// <param name="json">The JSON to parse.</param>
+ /// <returns>The parsed message.</returns>
+ public T ParseJson(string json)
+ {
+ T message = factory();
+ JsonParser.Default.Merge(message, json);
+ return message;
+ }
}
}