aboutsummaryrefslogtreecommitdiffhomepage
path: root/csharp/src
diff options
context:
space:
mode:
authorGravatar Jos Hickson <jos.hickson@gmail.com>2016-05-11 09:44:18 +0100
committerGravatar Jos Hickson <jos.hickson@gmail.com>2016-05-11 15:36:02 +0100
commit835fb947ccd1a65a7c1afec61940ed26101773e5 (patch)
tree4e456171f63b3414157b61c900d86548527ec14e /csharp/src
parent2b22b611a8af9e9d06491de2ebcc5d9b962e544c (diff)
Fixed parsing of BoolValue.
Diffstat (limited to 'csharp/src')
-rw-r--r--csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs7
-rw-r--r--csharp/src/Google.Protobuf/JsonParser.cs3
2 files changed, 9 insertions, 1 deletions
diff --git a/csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs b/csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs
index 5b7185dc..18d18be3 100644
--- a/csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs
+++ b/csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs
@@ -417,5 +417,12 @@ namespace Google.Protobuf.WellKnownTypes
TestWellKnownTypes.Descriptor.Fields[TestWellKnownTypes.StringFieldFieldNumber].Accessor.Clear(message);
Assert.IsNull(message.StringField);
}
+
+ [Test]
+ public void GivenBoolValueWhenPerformingRoundTripEncodingViaJsonThenShouldNotExpectObjectAtTopLevel()
+ {
+ var value = new BoolValue { Value = true };
+ Assert.AreEqual(value, JsonParser.Default.Parse<BoolValue>(JsonFormatter.Default.Format(value)));
+ }
}
}
diff --git a/csharp/src/Google.Protobuf/JsonParser.cs b/csharp/src/Google.Protobuf/JsonParser.cs
index d738ebb0..6b6f2d9a 100644
--- a/csharp/src/Google.Protobuf/JsonParser.cs
+++ b/csharp/src/Google.Protobuf/JsonParser.cs
@@ -86,7 +86,8 @@ namespace Google.Protobuf
{ FloatValue.Descriptor.FullName, MergeWrapperField },
{ DoubleValue.Descriptor.FullName, MergeWrapperField },
{ BytesValue.Descriptor.FullName, MergeWrapperField },
- { StringValue.Descriptor.FullName, MergeWrapperField }
+ { StringValue.Descriptor.FullName, MergeWrapperField },
+ { BoolValue.Descriptor.FullName, MergeWrapperField }
};
// Convenience method to avoid having to repeat the same code multiple times in the above