Newtonsoft.Json.JsonValidatingReader.Read C# (CSharp) Method

Read() public method

Reads the next JSON token from the stream.
public Read ( ) : bool
return bool
        public override bool Read()
        {
            if (!_reader.Read())
            {
                return false;
            }

            if (_reader.TokenType == JsonToken.Comment)
            {
                return true;
            }

            ValidateCurrentToken();
            return true;
        }

Usage Example

        /// <summary>
        /// Verifies Json literal content 
        /// </summary>
        /// <param name="content">the Json literal to be verified</param>
        /// <param name="result">output paramter of test result</param>
        /// <returns>true if verification passes; false otherwiser</returns>
        public bool Verify(string content, out TestResult result)
        {
            using (var stringReader = new StringReader(content))
            {
                using (JsonTextReader rdr = new JsonTextReader(stringReader))
                {
                    using (JsonValidatingReader vr = new JsonValidatingReader(rdr))
                    {
                        vr.Schema = this.schema;

                        try
                        {
                            while (vr.Read())
                            {
                                // Ignore
                            }

                            result = new TestResult();
                            return true;
                        }
                        catch (JsonSchemaException jex)
                        {
                            result = new TestResult() { LineNumberInError = jex.LineNumber, ErrorDetail = jex.Message };
                            return false;
                        }
                    }
                }
            }
        }
All Usage Examples Of Newtonsoft.Json.JsonValidatingReader::Read