Lines Matching defs:json
72 var json = "{ \"mapInt32Int32\": { \"" + keyText + "\" : \"1\" } }";
73 Assert.Throws<InvalidProtocolBufferException>(() => JsonParser.Default.Parse<TestMap>(json));
79 var json = "{ \"single_int32\": 10 }";
81 Assert.AreEqual(expected, TestAllTypes.Parser.ParseJson(json));
132 var json = new JsonFormatter(new JsonFormatter.Settings(true)).Format(message);
133 var parsed = JsonParser.Default.Parse<TestWellKnownTypes>(json);
148 public void Wrappers_Standalone(System.Type wrapperType, string json, object expectedValue)
155 JsonParser.Default.Merge(parsed, json);
163 string json = "{\"valueField\": null}";
164 var message = JsonParser.Default.Parse<TestWellKnownTypes>(json);
199 string json = "{ \"repeated_foreign_message\": [null] }";
200 Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
206 string json = "{ \"repeated_foreign_message\": null }";
207 Assert.AreEqual(new TestAllTypes(), TestAllTypes.Parser.ParseJson(json));
214 public void MapField_NullValueProhibited(string json)
216 Assert.Throws<InvalidProtocolBufferException>(() => TestMap.Parser.ParseJson(json));
222 string json = "{ \"mapInt32Int32\": null }";
223 Assert.AreEqual(new TestMap(), TestMap.Parser.ParseJson(json));
238 var json = JsonFormatter.Default.Format(message);
239 var parsed = JsonParser.Default.Parse<T>(json);
252 string json = "{ \"singleInt32\": \"" + jsonValue + "\"}";
253 var parsed = TestAllTypes.Parser.ParseJson(json);
271 string json = "{ \"singleInt32\": \"" + jsonValue + "\"}";
272 Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
281 string json = "{ \"singleUint32\": \"" + jsonValue + "\"}";
282 var parsed = TestAllTypes.Parser.ParseJson(json);
292 string json = "{ \"singleUint32\": \"" + jsonValue + "\"}";
293 Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
304 string json = "{ \"singleInt64\": \"" + jsonValue + "\"}";
305 var parsed = TestAllTypes.Parser.ParseJson(json);
315 string json = "{ \"singleInt64\": \"" + jsonValue + "\"}";
316 Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
325 string json = "{ \"singleUint64\": \"" + jsonValue + "\"}";
326 var parsed = TestAllTypes.Parser.ParseJson(json);
336 string json = "{ \"singleUint64\": \"" + jsonValue + "\"}";
337 Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
361 string json = "{ \"singleDouble\": \"" + jsonValue + "\"}";
362 var parsed = TestAllTypes.Parser.ParseJson(json);
389 string json = "{ \"singleDouble\": \"" + jsonValue + "\"}";
390 Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
404 string json = "{ \"singleFloat\": \"" + jsonValue + "\"}";
405 var parsed = TestAllTypes.Parser.ParseJson(json);
419 string json = "{ \"singleFloat\": \"" + jsonValue + "\"}";
420 Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
436 string json = "{ \"singleInt32\": " + jsonValue + "}";
437 var parsed = TestAllTypes.Parser.ParseJson(json);
454 string json = "{ \"singleInt32\": " + jsonValue + "}";
455 Assert.Throws(expectedExceptionType, () => TestAllTypes.Parser.ParseJson(json));
464 string json = "{ \"singleUint32\": " + jsonValue + "}";
465 var parsed = TestAllTypes.Parser.ParseJson(json);
475 string json = "{ \"singleUint32\": " + jsonValue + "}";
476 Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
489 string json = "{ \"singleInt64\": " + jsonValue + "}";
490 var parsed = TestAllTypes.Parser.ParseJson(json);
503 string json = "{ \"singleInt64\": " + jsonValue + "}";
504 Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
515 string json = "{ \"singleUint64\": " + jsonValue + "}";
516 var parsed = TestAllTypes.Parser.ParseJson(json);
526 string json = "{ \"singleUint64\": " + jsonValue + "}";
527 Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
548 string json = "{ \"singleDouble\": " + jsonValue + "}";
549 var parsed = TestAllTypes.Parser.ParseJson(json);
565 string json = "{ \"singleDouble\": " + jsonValue + "}";
566 Assert.Throws<InvalidJsonException>(() => TestAllTypes.Parser.ParseJson(json));
580 string json = "{ \"singleFloat\": " + jsonValue + "}";
581 var parsed = TestAllTypes.Parser.ParseJson(json);
595 string json = "{ \"singleFloat\": " + jsonValue + "}";
596 Assert.Throws(expectedExceptionType, () => TestAllTypes.Parser.ParseJson(json));
644 string json = WrapInQuotes(jsonValue);
645 var parsed = Timestamp.Parser.ParseJson(json);
671 string json = WrapInQuotes(jsonValue);
672 Assert.Throws<InvalidProtocolBufferException>(() => Timestamp.Parser.ParseJson(json));
761 string json = WrapInQuotes(jsonValue);
762 var parsed = Duration.Parser.ParseJson(json);
791 string json = WrapInQuotes(jsonValue);
792 Assert.Throws<InvalidProtocolBufferException>(() => Duration.Parser.ParseJson(json));
807 string json = WrapInQuotes(jsonValue);
808 var parsed = FieldMask.Parser.ParseJson(json);
816 string json = WrapInQuotes(jsonValue);
817 Assert.Throws<InvalidProtocolBufferException>(() => FieldMask.Parser.ParseJson(json));
827 var json = formatter.Format(original); // This is tested in JsonFormatterTest
829 Assert.AreEqual(original, parser.Parse<Any>(json));
841 string json = "{ \"@type\": \"custom.prefix/middle-part/protobuf_unittest3.TestAllTypes\", \"singleInt32\": 10 }";
842 Assert.AreEqual(original, parser.Parse<Any>(json));
848 string json = "{ \"@type\": \"type.googleapis.com/bogus\" }";
849 Assert.Throws<InvalidOperationException>(() => Any.Parser.ParseJson(json));
855 string json = "{ \"foo\": \"bar\" }";
856 Assert.Throws<InvalidProtocolBufferException>(() => Any.Parser.ParseJson(json));
866 var json = formatter.Format(original); // This is tested in JsonFormatterTest
868 Assert.AreEqual(original, parser.Parse<Any>(json));
882 var json = formatter.Format(message);
884 Assert.AreEqual(message, parser.Parse(json, TestWellKnownTypes.Descriptor));
890 string json = "{} 10";
891 Assert.Throws<InvalidJsonException>(() => TestAllTypes.Parser.ParseJson(json));
916 string json = "{ \"singleBytes\": \"" + badBase64 + "\" }";
917 Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
926 string json = "{ \"singleForeignEnum\": " + value + " }";
927 var parsed = TestAllTypes.Parser.ParseJson(json);
936 string json = "{ \"singleForeignEnum\": " + value + " }";
937 Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
943 string json = "{ \"oneofString\": \"x\", \"oneofUint32\": 10 }";
944 Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
950 string json = "{ \"unknownField\": 10, \"singleString\": \"x\" }";
951 Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
957 string json = "{ \"FieldName13\": 0 }";
958 var parsed = TestAllTypesProto2.Parser.ParseJson(json);
972 string json = "{ \"unknownField\": " + value + ", \"singleString\": \"x\" }";
973 var actual = parser.Parse<TestAllTypes>(json);
981 string json = "{ \"nullValue\": null }";
982 var message = NullValueOutsideStruct.Parser.ParseJson(json);
990 string json = "{ \"nullValue\": null }";
991 var message = NullValueNotInOneof.Parser.ParseJson(json);
1001 string json = "{ \"nullValue\": \"NULL_VALUE\" }";
1002 var message = NullValueOutsideStruct.Parser.ParseJson(json);
1010 string json = "{ \"nullValue\": \"NULL_VALUE\" }";
1011 var message = NullValueNotInOneof.Parser.ParseJson(json);