Exemple #1
0
        private static ScannerData ScanArray(string json, int index)
        {
            var list = new List <JSONObject>();

            var nextTokenIndex = SkipWhitespace(json, index + 1);

            if (json[nextTokenIndex] == ArrayEnd)
            {
                return(new ScannerData(JSONObject.CreateArray(list), nextTokenIndex + 1));
            }

            while (json[index] != ArrayEnd)
            {
                ++index;
                var result = Scan(json, index);
                index = SkipWhitespace(json, result.Index);
                if (json[index] != ArraySeparator && json[index] != ArrayEnd)
                {
                    throw new ParseError("Expecting array separator (,) or array end (])", index);
                }
                list.Add(result.Result);
            }
            return(new ScannerData(JSONObject.CreateArray(list), index + 1));
        }