/// <summary>
                /// Parses out a JSON property AST node with a jsonTextReader.
                /// </summary>
                /// <param name="jsonTextReader">The reader to use as a lexer / tokenizer</param>
                /// <returns>JSON property AST node</returns>
                private static ObjectProperty ParsePropertyNode(IJsonReader jsonTextReader)
                {
                    FieldNameNode fieldName = FieldNameNode.Create((ArraySegment<byte>)jsonTextReader.GetBufferedRawJsonToken());

                    // Consume the fieldname from the jsonreader
                    jsonTextReader.Read();

                    JsonTextNode value = JsonTextParser.ParseNode(jsonTextReader);
                    return new ObjectProperty(fieldName, value);
                }
コード例 #2
0
                /// <summary>
                /// Parses out a JSON property AST node with a jsonTextReader.
                /// </summary>
                /// <param name="jsonTextReader">The reader to use as a lexer / tokenizer</param>
                /// <returns>JSON property AST node</returns>
                private static ObjectProperty ParsePropertyNode(IJsonTextReaderPrivateImplementation jsonTextReader)
                {
                    ReadOnlyMemory <byte> bufferedRawJsonToken = jsonTextReader.GetBufferedJsonToken().Memory;
                    FieldNameNode         fieldName            = FieldNameNode.Create(Utf8Memory.UnsafeCreateNoValidation(bufferedRawJsonToken));

                    // Consume the fieldname from the jsonreader
                    jsonTextReader.Read();

                    JsonTextNavigatorNode value = Parser.ParseNode(jsonTextReader);

                    return(new ObjectProperty(fieldName, value));
                }
コード例 #3
0
                /// <summary>
                /// Parses out a JSON property AST node with a jsonTextReader.
                /// </summary>
                /// <param name="jsonTextReader">The reader to use as a lexer / tokenizer</param>
                /// <returns>JSON property AST node</returns>
                private static ObjectProperty ParsePropertyNode(IJsonReader jsonTextReader)
                {
                    if (!jsonTextReader.TryGetBufferedRawJsonToken(out ReadOnlyMemory <byte> bufferedRawJsonToken))
                    {
                        throw new InvalidOperationException("Failed to get the buffered raw json token.");
                    }

                    FieldNameNode fieldName = FieldNameNode.Create(Utf8Memory.UnsafeCreateNoValidation(bufferedRawJsonToken));

                    // Consume the fieldname from the jsonreader
                    jsonTextReader.Read();

                    JsonTextNavigatorNode value = Parser.ParseNode(jsonTextReader);

                    return(new ObjectProperty(fieldName, value));
                }