fastBinaryJSON/BJsonParser.cs

(开头部分) 7KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Text;

namespace fastBinaryJSON
{
    internal sealed class BJsonParser
    {
        readonly byte[] json;
        int index;
        bool _useUTC = true;

        internal BJsonParser(byte[] json, bool useUTC)
        {
            this.json = json;
            _useUTC = useUTC;
        }

        public object Decode()
        {
            bool b = false;
            return ParseValue(out b);
        }

        private Dictionary<string, object> ParseObject()
        {
            Dictionary<string, object> dic = new Dictionary<string, object>();
            bool breakparse = false;
            while (!breakparse)
            {
                byte t = GetToken();
                if (t == TOKENS.COMMA)
                    continue;
                if (t == TOKENS.DOC_END)
                    break;
                string key = "";
                if (t != TOKENS.NAME)
                    throw new Exception("excpecting a name field");
                key = ParseName();
                t = GetToken();
                if (t != TOKENS.COLON)
                    throw new Exception("expecting a colon");
                object val = ParseValue(out breakparse);

                if (breakparse == false)
                {
                    dic.Add(key, val);
                }
            }
            return dic;
        }

        private string ParseName()
        {
            byte c = json[index++];
            string s = Reflection.Instance.utf8.GetString(json, index, c);
            index += c;
            return s;
后面还有 228 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。