예제 #1
0
파일: JSONDoc.cs 프로젝트: perforce/P4VS
        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);
            }
        }
예제 #2
0
파일: JSONField.cs 프로젝트: perforce/P4VS
        public JSONArray(string jsonStr)
        {
            Value = new List <JSONField>();
            IList <JSONToken> tokens = JSONDoc.Tokenize(jsonStr);

            this.Parse(tokens);
        }
예제 #3
0
파일: JSONDoc.cs 프로젝트: perforce/P4VS
        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);
            }
        }
예제 #4
0
파일: JSONField.cs 프로젝트: perforce/P4VS
        public JSONObject(string jsonStr)
        {
            Value = new Dictionary <string, JSONField>();
            IList <JSONToken> tokens = JSONDoc.Tokenize(jsonStr);

            this.Parse(tokens);
        }