Lines Matching defs:token
146 /// token should be a "start object" token, but wrapper types and nullity can invalidate
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".
167 var token = tokenizer.Next();
168 if (token.Type != JsonToken.TokenType.StartObject)
180 token = tokenizer.Next();
181 if (token.Type == JsonToken.TokenType.EndObject)
185 if (token.Type != JsonToken.TokenType.Name)
187 throw new InvalidOperationException("Unexpected token type " + token.Type);
189 string name = token.StringValue;
222 var token = tokenizer.Next();
223 if (token.Type == JsonToken.TokenType.Null)
225 // Clear the field if we see a null token, unless it's for a singular field of type
236 tokenizer.PushBack(token);
255 var token = tokenizer.Next();
256 if (token.Type != JsonToken.TokenType.StartArray)
258 throw new InvalidProtocolBufferException("Repeated field value was not an array. Token type: " + token.Type);
264 token = tokenizer.Next();
265 if (token.Type == JsonToken.TokenType.EndArray)
269 tokenizer.PushBack(token);
282 var token = tokenizer.Next();
283 if (token.Type != JsonToken.TokenType.StartObject)
299 token = tokenizer.Next();
300 if (token.Type == JsonToken.TokenType.EndObject)
304 object key = ParseMapKey(keyField, token.StringValue);
328 var token = tokenizer.Next();
329 if (token.Type == JsonToken.TokenType.Null)
357 tokenizer.PushBack(token);
364 switch (token.Type)
370 return token.Type == JsonToken.TokenType.True;
376 return ParseSingleStringValue(field, token.StringValue);
377 // Note: not passing the number value itself here, as we may end up storing the string value in the token too.
379 return ParseSingleNumberValue(field, token);
383 throw new InvalidProtocolBufferException("Unsupported JSON token type " + token.Type + " for field type " + fieldType);
483 throw new InvalidOperationException("Unexpected token type: " + firstToken.Type);
489 var token = tokenizer.Next();
490 if (token.Type != JsonToken.TokenType.StartObject)
494 tokenizer.PushBack(token);
502 // Record the token stream until we see the @type property. At that point, we can take the value, consult
506 var token = tokenizer.Next();
507 if (token.Type != JsonToken.TokenType.StartObject)
515 while (token.Type != JsonToken.TokenType.Name ||
516 token.StringValue != JsonFormatter.AnyTypeUrlField ||
519 tokens.Add(token);
520 token = tokenizer.Next();
528 // Don't add the @type property or its value to the recorded token list
529 token = tokenizer.Next();
530 if (token.Type != JsonToken.TokenType.StringValue)
534 string typeUrl = token.StringValue;
543 // Now replay the token stream we've already read and anything that remains of the object, just parsing it
563 // in the given JSON token stream, we should *only* have tokens of start-object, name("value"), the value
567 var token = tokenizer.Next(); // Definitely start-object; checked in previous method
568 token = tokenizer.Next();
570 if (token.Type != JsonToken.TokenType.Name || token.StringValue != JsonFormatter.AnyWellKnownTypeValueField)
575 token = tokenizer.Next();
576 if (token.Type != JsonToken.TokenType.EndObject)
578 throw new InvalidProtocolBufferException($"Expected end-object token after @type/value for well-known type");
618 private static object ParseSingleNumberValue(FieldDescriptor field, JsonToken token)
620 double value = token.NumberValue;
801 private static void MergeTimestamp(IMessage message, JsonToken token)
803 if (token.Type != JsonToken.TokenType.StringValue)
807 var match = TimestampRegex.Match(token.StringValue);
810 throw new InvalidProtocolBufferException($"Invalid Timestamp value: {token.StringValue}");
842 throw new InvalidProtocolBufferException("Invalid Timestamp value: " + token.StringValue);
847 throw new InvalidProtocolBufferException("Invalid Timestamp value: " + token.StringValue);
865 throw new InvalidProtocolBufferException("Invalid Timestamp value: " + token.StringValue);
873 throw new InvalidProtocolBufferException("Invalid Timestamp value: " + token.StringValue);
877 private static void MergeDuration(IMessage message, JsonToken token)
879 if (token.Type != JsonToken.TokenType.StringValue)
883 var match = DurationRegex.Match(token.StringValue);
886 throw new InvalidProtocolBufferException("Invalid Duration value: " + token.StringValue);
893 throw new InvalidProtocolBufferException("Invalid Duration value: " + token.StringValue);
910 throw new InvalidProtocolBufferException($"Invalid Duration value: {token.StringValue}");
917 throw new InvalidProtocolBufferException($"Invalid Duration value: {token.StringValue}");
921 private static void MergeFieldMask(IMessage message, JsonToken token)
923 if (token.Type != JsonToken.TokenType.StringValue)
928 string[] jsonPaths = token.StringValue.Split(FieldMaskPathSeparators, StringSplitOptions.RemoveEmptyEntries);