Thanks Jon. I have replied on the issue. On Tuesday, January 10, 2017 at 7:21:46 PM UTC+5:30, Jon Skeet wrote: > > Okay, I've tried it with your message - and it deserializes that JSON just > fine for me. I've updated the issue - could you look there and reply to the > questions? > (It would be better to keep it on github than on the mailing list.) > > Jon > > > On Tuesday, 10 January 2017 08:03:48 UTC-5, Jon Skeet wrote: >> >> Thanks for reporting this - I've copied it into a github issue: >> https://github.com/google/protobuf/issues/2574 >> >> I'll look into it as soon as I can. (Although I'm at a conference this >> week, making it slightly tricky.) >> I thought I had tests for all of the well-known types, so it's certainly >> surprising... >> >> Jon >> >> On Tuesday, 10 January 2017 04:59:51 UTC-5, Ajay Bhandari wrote: >>> >>> Hi, >>> I have simple proto definition like below and through the protoc >>> compiler I am able to use the generated C# message class to covert object >>> to byte array, de-serialize the object from byte array using the message >>> parser etc. >>> >>> When I try to use the JSON Formatter & parser, I am able to serialize >>> the same to JSON string, but during deserialization the JSON parser throws >>> an error about not able to convert System.UInt32 (.NET) to Google. >>> >>> Will appreciate any help in resolving this. I am using >>> Google.Protobuf.3.1.0 and Google.Protobuf.Tools.3.1.0 nuget packages >>> >>> Thanks. >>> >>> >>> *PROTO=====* >>> syntax = "proto3"; >>> package testpack; >>> option csharp_namespace = "Test.v1"; >>> >>> // import proto definitions from google protobuf >>> import "wrappers.proto"; >>> import "timestamp.proto"; >>> >>> message TestMessage { >>> google.protobuf.UInt32Value testUintProperty = 1; >>> google.protobuf.Int32Value testIntProperty = 2; >>> google.protobuf.BoolValue testBoolProperty = 3; >>> google.protobuf.Timestamp timestamp = 4; >>> } >>> >>> >>> *CODE SNIPPTES (C#)==================* >>> // this works >>> var testMessage = <some method to create TestMessage object using >>> the generated TestMessage class> >>> var tmBytes = testMessage.ToByteArray(); >>> var deserializedTestMessage = TestMessage.Parser.ParseFrom(tmBytes); >>> >>> // this works - json below >>> JsonFormatter jsf = new JsonFormatter(new >>> JsonFormatter.Settings(true)); >>> string jsonString = jsf.Format(testMessage); >>> >>> // this throws error - see exception details below >>> var deserializedTestMessageFromJson = >>> JsonParser.Default.Parse<TestMessage>(jsonString); >>> >>> >>> *JSON====* >>> { "testUintproperty": 1024, "testIntproperty": 300, "testBoolproperty": >>> true, "timestamp": "2017-01-10T09:46:53.218325200Z" } >>> >>> >>> >>> *SYSTEMEXCEPTION MESSAGE==========================* >>> Unable to cast object of type 'System.UInt32' to type >>> 'Google.Protobuf.WellKnownTypes.UInt32Value'. >>> >>> >>> *STACK TRACE===========* >>> at lambda_method(Closure , IMessage , Object ) >>> at Google.Protobuf.Reflection.SingleFieldAccessor.SetValue(IMessage >>> message, Object value) >>> at Google.Protobuf.JsonParser.MergeField(IMessage message, >>> FieldDescriptor field, JsonTokenizer tokenizer) >>> at Google.Protobuf.JsonParser.Merge(IMessage message, JsonTokenizer >>> tokenizer) >>> at Google.Protobuf.JsonParser.Merge(IMessage message, TextReader >>> jsonReader) >>> at Google.Protobuf.JsonParser.Parse[T](TextReader jsonReader) >>> at Google.Protobuf.JsonParser.Parse[T](String json) >>> at >>> DeviceSimulator.Program.<SendDeviceToCloudTestMessagesAsync>d__3.MoveNext() >>> ... >>> >>
-- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
