Пример #1
0
        /// <summary>
        /// Parses a string to a <see cref="NiklasKarl.Json.JsonValue"/>.
        /// </summary>
        /// <param name="data">The reader from which to read the data.</param>
        /// <returns>The resulting <see cref="NiklasKarl.Json.JsonValue"/>.</returns>
        internal static JsonValue ParseValue(TextReader reader)
        {
            JsonValue value = null;
            using (JsonParser parser = new JsonParser(reader))
            {
                value = parser.ParseValue();
                parser.EnsureEndOfData();
            }

            return value;
        }
Пример #2
0
        /// <summary>
        /// Parses a string to a <see cref="NiklasKarl.Json.JsonNumber"/>.
        /// </summary>
        /// <param name="data">The reader from which to read the data.</param>
        /// <returns>The resulting <see cref="NiklasKarl.Json.JsonNumber"/>.</returns>
        internal static JsonNumber ParseNumber(TextReader reader)
        {
            JsonNumber number = null;
            using (JsonParser parser = new JsonParser(reader))
            {
                number = new JsonNumber(parser.ParseNumber());
                parser.EnsureEndOfData();
            }

            return number;
        }
Пример #3
0
        /// <summary>
        /// Parses a string to a <see cref="NiklasKarl.Json.JsonArray"/>.
        /// </summary>
        /// <param name="reader">The reader from which to read the data.</param>
        /// <returns>The resulting <see cref="NiklasKarl.Json.JsonArray"/>.</returns>
        internal static JsonArray ParseArray(TextReader reader)
        {
            JsonArray array = null;
            using (JsonParser parser = new JsonParser(reader))
            {
                array = parser.ParseArray();
                parser.EnsureEndOfData();
            }

            return array;
        }
Пример #4
0
        /// <summary>
        /// Parses a string to a <see cref="NiklasKarl.Json.JsonString"/>.
        /// </summary>
        /// <param name="data">The reader from which to read the data.</param>
        /// <returns>The resulting <see cref="NiklasKarl.Json.JsonString"/>.</returns>
        internal static JsonString ParseString(TextReader reader)
        {
            JsonString str = null;
            using (JsonParser parser = new JsonParser(reader))
            {
                str = new JsonString(parser.ParseString());
                parser.EnsureEndOfData();
            }

            return str;
        }
Пример #5
0
        /// <summary>
        /// Parses a string to a <see cref="NiklasKarl.Json.JsonObject"/>.
        /// </summary>
        /// <param name="data">The reader from which to read the data.</param>
        /// <returns>The resulting <see cref="NiklasKarl.Json.JsonObject"/>.</returns>
        internal static JsonObject ParseObject(TextReader reader)
        {
            JsonObject obj = null;
            using (JsonParser parser = new JsonParser(reader))
            {
                obj = parser.ParseObject();
                parser.EnsureEndOfData();
            }

            return obj;
        }