Ejemplo n.º 1
0
        public bool LoadJSONDoc(TextReader jsonStr)
        {
            try
            {
                this.Value.Clear();
#if DEBUG
                StreamContentBuf = new StringBuilder(4 * 4096);
#endif
                IList <JSONToken> tokens = JSONDoc.Tokenize(jsonStr);
#if DEBUG
                StreamContent = StreamContentBuf.ToString();
#endif
                if ((tokens[0] is StartBlock) == false)
                {
                    throw new Exception("JSON document must start with a '{'");
                }
                if ((tokens[tokens.Count - 1] is EndBlock) == false)
                {
                    throw new Exception("JSON document must end with a '}'");
                }

                int idx = 0;
                this.Parse(tokens, ref idx);

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        public JSONArray(string jsonStr)
        {
            Value = new List <JSONField>();
            IList <JSONToken> tokens = JSONDoc.Tokenize(jsonStr);

            this.Parse(tokens);
        }
Ejemplo n.º 3
0
        public bool LoadJSONDoc(string jsonStr)
        {
            try
            {
                this.Value.Clear();

                IList <JSONToken> tokens = JSONDoc.Tokenize(jsonStr);

                if ((tokens[0] is StartBlock) == false)
                {
                    throw new Exception("JSON document must start with a '{'");
                }
                if ((tokens[tokens.Count - 1] is EndBlock) == false)
                {
                    throw new Exception("JSON document must end with a '}'");
                }

                int idx = 0;
                this.Parse(tokens, ref idx);

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
        public JSONObject(string jsonStr)
        {
            Value = new Dictionary <string, JSONField>();
            IList <JSONToken> tokens = JSONDoc.Tokenize(jsonStr);

            this.Parse(tokens);
        }