Lines Matching +full:parse +full:- +full:json
2 // Protocol Buffers - Google's data interchange format
4 // https://developers.google.com/protocol-buffers/
47 /// Reflection-based converter from JSON to messages.
51 /// Instances of this class are thread-safe, with no mutable state.
54 /// This is a simple start to get JSON parsing working. As it's reflection-based,
55 /// it's not as quick as baking calls into generated messages - but is a simpler implementation.
61 // Note: using 0-9 instead of \d to ensure no non-ASCII digits.
63 …(?<datetime>[0-9]{4}-[01][0-9]-[0-3][0-9]T[012][0-9]:[0-5][0-9]:[0-5][0-9])(?<subseconds>\.[0-9]{1…
64 …tic readonly Regex DurationRegex = new Regex(@"^(?<sign>-)?(?<int>[0-9]{1,12})(?<subseconds>\.[0-9…
71 …// TODO: Consider introducing a class containing parse state of the parser, tokenizer and depth. T…
119 /// Parses <paramref name="json"/> and merges the information into the given message.
121 /// <param name="message">The message to merge the JSON information into.</param>
122 /// <param name="json">The JSON to parse.</param>
123 internal void Merge(IMessage message, string json) in Merge() argument
125 Merge(message, new StringReader(json)); in Merge()
129 …/// Parses JSON read from <paramref name="jsonReader"/> and merges the information into the given …
131 /// <param name="message">The message to merge the JSON information into.</param>
132 /// <param name="jsonReader">Reader providing the JSON to parse.</param>
140 throw new InvalidProtocolBufferException("Expected end of JSON after object"); in Merge()
148 … /// of tokens provided by the tokenizer. This token stream is assumed to be valid JSON, with the
149 … /// tokenizer performing that validation - but not every token stream is valid "protobuf JSON".
165 // Well-known types with no special handling continue in the normal way. in Merge()
174 // All the oneof fields we've already accounted for - we can only see each of them once. in Merge()
281 …// Map fields are always objects, even if the values are well-known types: ParseSingleValue handle… in MergeMapField()
347 // Parse wrapper types as their constituent types. in ParseSingleValue()
383 …throw new InvalidProtocolBufferException("Unsupported JSON token type " + token.Type + " for field… in ParseSingleValue()
388 /// Parses <paramref name="json"/> into a new message.
391 /// <param name="json">The JSON to parse.</param>
392 … /// <exception cref="InvalidJsonException">The JSON does not comply with RFC 7159</exception>
393 …/// <exception cref="InvalidProtocolBufferException">The JSON does not represent a Protocol Buffer…
394 public T Parse<T>(string json) where T : IMessage, new()
396 ProtoPreconditions.CheckNotNull(json, nameof(json));
397 return Parse<T>(new StringReader(json));
401 /// Parses JSON read from <paramref name="jsonReader"/> into a new message.
404 /// <param name="jsonReader">Reader providing the JSON to parse.</param>
405 … /// <exception cref="InvalidJsonException">The JSON does not comply with RFC 7159</exception>
406 …/// <exception cref="InvalidProtocolBufferException">The JSON does not represent a Protocol Buffer…
407 public T Parse<T>(TextReader jsonReader) where T : IMessage, new()
416 /// Parses <paramref name="json"/> into a new message.
418 /// <param name="json">The JSON to parse.</param>
419 /// <param name="descriptor">Descriptor of message type to parse.</param>
420 … /// <exception cref="InvalidJsonException">The JSON does not comply with RFC 7159</exception>
421 …/// <exception cref="InvalidProtocolBufferException">The JSON does not represent a Protocol Buffer…
422 public IMessage Parse(string json, MessageDescriptor descriptor) in Parse() method in Google.Protobuf.JsonParser
424 ProtoPreconditions.CheckNotNull(json, nameof(json)); in Parse()
426 return Parse(new StringReader(json), descriptor); in Parse()
430 /// Parses JSON read from <paramref name="jsonReader"/> into a new message.
432 /// <param name="jsonReader">Reader providing the JSON to parse.</param>
433 /// <param name="descriptor">Descriptor of message type to parse.</param>
434 … /// <exception cref="InvalidJsonException">The JSON does not comply with RFC 7159</exception>
435 …/// <exception cref="InvalidProtocolBufferException">The JSON does not represent a Protocol Buffer…
436 public IMessage Parse(TextReader jsonReader, MessageDescriptor descriptor) in Parse() method in Google.Protobuf.JsonParser
562 …// Well-known types end up in a property called "value" in the JSON. As there's no longer a @type …
563 …// in the given JSON token stream, we should *only* have tokens of start-object, name("value"), th…
564 // itself, and then end-object.
567 var token = tokenizer.Next(); // Definitely start-object; checked in previous method in MergeWellKnownTypeAnyBody()
572 …on($"Expected '{JsonFormatter.AnyWellKnownTypeValueField}' property for well-known type Any body"); in MergeWellKnownTypeAnyBody()
578 …throw new InvalidProtocolBufferException($"Expected end-object token after @type/value for well-kn… in MergeWellKnownTypeAnyBody()
602 return ParseNumericString(keyText, int.Parse); in ParseMapKey()
605 return ParseNumericString(keyText, uint.Parse); in ParseMapKey()
609 return ParseNumericString(keyText, long.Parse); in ParseMapKey()
612 return ParseNumericString(keyText, ulong.Parse); in ParseMapKey()
671 …throw new InvalidProtocolBufferException($"Unsupported conversion from JSON number for field type … in ParseMapKey()
711 return ParseNumericString(text, int.Parse); in ParseMapKey()
714 return ParseNumericString(text, uint.Parse); in ParseMapKey()
718 return ParseNumericString(text, long.Parse); in ParseMapKey()
721 return ParseNumericString(text, ulong.Parse); in ParseMapKey()
723 double d = ParseNumericString(text, double.Parse); in ParseMapKey()
727 float f = ParseNumericString(text, float.Parse); in ParseMapKey()
739 …throw new InvalidProtocolBufferException($"Unsupported conversion from JSON string for field type … in ParseMapKey()
765 else if (text.StartsWith("-0") && text.Length > 2)
788 … /// This corrects the lenient whitespace handling of double.Parse/float.Parse, as well as the
789 /// way that Mono parses out-of-range values as infinity.
794 (isNegativeInfinity && text != "-Infinity") || in ValidateInfinityAndNan()
820 "yyyy-MM-dd'T'HH:mm:ss", in MergeTimestamp()
828 // This should always work, as we've got 1-9 digits. in MergeTimestamp()
829 … int parsedFraction = int.Parse(subseconds.Substring(1), CultureInfo.InvariantCulture); in MergeTimestamp()
835 …s is the amount we need to *subtract* from the local time to get to UTC - hence - => +1 and vice v… in MergeTimestamp()
836 int sign = offset[0] == '-' ? 1 : -1; in MergeTimestamp()
837 int hours = int.Parse(offset.Substring(1, 2), CultureInfo.InvariantCulture); in MergeTimestamp()
838 int minutes = int.Parse(offset.Substring(4, 2)); in MergeTimestamp()
846 …// This is an offset of -00:00, which means "unknown local offset". It makes no sense for a timest… in MergeTimestamp()
856 nanosToAdd = nanosToAdd - Duration.NanosecondsPerSecond; in MergeTimestamp()
862 // anywhere, but we shouldn't parse it. in MergeTimestamp()
896 var multiplier = sign == "-" ? -1 : 1; in MergeDuration()
900 long seconds = long.Parse(secondsText, CultureInfo.InvariantCulture) * multiplier; in MergeDuration()
904 // This should always work, as we've got 1-9 digits. in MergeDuration()
905 int parsedFraction = int.Parse(subseconds.Substring(1)); in MergeDuration()
968 builder.Append((char) (c + 'a' - 'A')); in ToSnakeCase()
988 /// Settings controlling JSON parsing.
1006 /// The maximum depth of messages to parse. Note that this limit only applies to parsing
1007 … /// messages, not collections - so a message within a collection within a message only counts as
1013 /// The type registry used to parse <see cref="Any"/> messages.
1033 /// <param name="recursionLimit">The maximum depth of messages to parse</param>
1041 /// <param name="recursionLimit">The maximum depth of messages to parse</param>
1042 … /// <param name="typeRegistry">The type registry used to parse <see cref="Any"/> messages</param>