• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# LitJson.JsonReader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中LitJson.JsonReader的典型用法代码示例。如果您正苦于以下问题:C# JsonReader类的具体用法?C# JsonReader怎么用?C# JsonReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JsonReader类属于LitJson命名空间,在下文中一共展示了JsonReader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CommentsTest

        public void CommentsTest()
        {
            string json = @"
                {
                    // This is the first property
                    ""foo"" : ""bar"",

                    /**
                     * This is the second property
                     **/
                     ""baz"": ""blah""
                }";

            JsonReader reader = new JsonReader (json);

            reader.Read ();
            reader.Read ();
            Assert.AreEqual ("foo", (string) reader.Value, "A1");

            reader.Read ();
            reader.Read ();
            Assert.AreEqual ("baz", (string) reader.Value, "A2");

            reader.Read ();
            reader.Read ();
            Assert.IsTrue (reader.EndOfJson, "A3");
        }
开发者ID:kvantetore,项目名称:litjson,代码行数:27,代码来源:JsonReaderTest.cs


示例2: DoubleTest

        public void DoubleTest()
        {
            string json = @"[ 0.0, -0.0, 3.1416, 8e-3, 7E-5, -128.000009,
                   144e+3, 0.1e2 ]";

            JsonReader reader = new JsonReader (json);
            reader.Read ();

            reader.Read ();
            Assert.AreEqual ((double) reader.Value, 0.0,
                             Double.Epsilon, "A1");
            reader.Read ();
            Assert.AreEqual ((double) reader.Value, 0.0,
                             Double.Epsilon, "A2");
            reader.Read ();
            Assert.AreEqual ((double) reader.Value, 3.1416,
                             Double.Epsilon, "A3");
            reader.Read ();
            Assert.AreEqual ((double) reader.Value, 0.008,
                             Double.Epsilon, "A4");
            reader.Read ();
            Assert.AreEqual ((double) reader.Value, 0.00007,
                             Double.Epsilon, "A5");
            reader.Read ();
            Assert.AreEqual ((double) reader.Value, -128.000009,
                             Double.Epsilon, "A6");
            reader.Read ();
            Assert.AreEqual ((double) reader.Value, 144000.0,
                             Double.Epsilon, "A7");
            reader.Read ();
            Assert.AreEqual ((double) reader.Value, 10.0,
                             Double.Epsilon, "A8");

            reader.Close ();
        }
开发者ID:kvantetore,项目名称:litjson,代码行数:35,代码来源:JsonReaderTest.cs


示例3: Read

 public static ZenSettings Read(string filePath)
 {
     string src = File.ReadAllText(filePath);
     src = SanitizeJSon(src);
     JsonReader reader = new JsonReader(src);
     return ReadZenSettings(reader);
 }
开发者ID:heon21st,项目名称:flashdevelop,代码行数:7,代码来源:ZenCoding.cs


示例4: DeserializeJson

 public static OSD DeserializeJson(Stream json)
 {
     using (StreamReader streamReader = new StreamReader(json))
     {
         JsonReader reader = new JsonReader(streamReader);
         return DeserializeJson(JsonMapper.ToObject(reader));
     }
 }
开发者ID:RavenB,项目名称:gridsearch,代码行数:8,代码来源:OSDJson.cs


示例5: ReadModules

 private void ReadModules(JsonReader reader)
 {
     while (reader.Read())
     {
         if (reader.Token == JsonToken.ArrayEnd) break;
         if (reader.Token == JsonToken.ObjectStart) ReadModule(reader);
     }
 }
开发者ID:Neverbirth,项目名称:flashdevelop,代码行数:8,代码来源:LibParser.cs


示例6: LitJsonReaderStrings

        public static void LitJsonReaderStrings ()
        {
            for (int i = 0; i < Common.Iterations; i++) {
                JsonReader reader = new JsonReader (Common.JsonStrings);

                while (reader.Read ());
            }
        }
开发者ID:chenchen2015,项目名称:litjson,代码行数:8,代码来源:BmLitJsonReader.cs


示例7: WriteJsonData

        public static void WriteJsonData(this JsonWriter writer, JsonData jsonData)
        {
            var reader = new JsonReader(jsonData.ToJson());

            while (reader.Read())
            {
                switch (reader.Token)
                {
                    case JsonToken.None:
                        break;
                    case JsonToken.ObjectStart:
                        writer.WriteObjectStart();
                        break;
                    case JsonToken.PropertyName:
                        writer.WritePropertyName(reader.Value.ToString());
                        break;
                    case JsonToken.ObjectEnd:
                        writer.WriteObjectEnd();
                        break;
                    case JsonToken.ArrayStart:
                        writer.WriteArrayStart();
                        break;
                    case JsonToken.ArrayEnd:
                        writer.WriteArrayEnd();
                        break;
                    case JsonToken.Int:
                        writer.Write((int)reader.Value);
                        break;
                    case JsonToken.Long:
                        writer.Write((long)reader.Value);
                        break;
                    case JsonToken.ULong:
                        writer.Write((ulong)reader.Value);
                        break;
                    case JsonToken.Double:
                        writer.Write((double)reader.Value);
                        break;
                    case JsonToken.String:
                        writer.Write((string)reader.Value);
                        break;
                    case JsonToken.Boolean:
                        writer.Write((bool)reader.Value);
                        break;
                    case JsonToken.Null:
                        break;
                    default:
                        break;
                }
            }
        }
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:50,代码来源:LitJsonExtensions.cs


示例8: BooleanTest

        public void BooleanTest()
        {
            string json = "[ true, false ]";

            JsonReader reader = new JsonReader (json);
            reader.Read ();

            reader.Read ();
            Assert.IsTrue ((bool) reader.Value, "A1");
            reader.Read ();
            Assert.IsTrue (! ((bool) reader.Value), "A2");

            reader.Close ();
        }
开发者ID:kvantetore,项目名称:litjson,代码行数:14,代码来源:JsonReaderTest.cs


示例9: ReadModule

 private void ReadModule(JsonReader reader)
 {
     // root/modules
     string prop = null;
     while (reader.Read())
     {
         if (reader.Token == JsonToken.ObjectEnd) break;
         if (reader.Token == JsonToken.PropertyName) prop = reader.Value.ToString();
         else if (reader.Token == JsonToken.ArrayStart)
         {
             if (prop == "types") ReadTypes(reader);
             else reader.SkipArray();
         }
         else if (reader.Token == JsonToken.ObjectStart) {
             reader.SkipObject();
         }
     }
 }
开发者ID:Neverbirth,项目名称:flashdevelop,代码行数:18,代码来源:LibParser.cs


示例10: LitJsonReaderFirstProperty

        public static void LitJsonReaderFirstProperty ()
        {
            for (int i = 0; i < Common.Iterations; i++) {
                bool found = false;

                JsonReader reader = new JsonReader (Common.JsonText);

                while (reader.Read ()) {
                    if (reader.Token == JsonToken.PropertyName &&
                        (string) reader.Value == "FirstProperty") {
                        found = true;
                        break;
                    }
                }

                if (! found)
                    Console.WriteLine ("FirstProperty not found!");
            }
        }
开发者ID:chenchen2015,项目名称:litjson,代码行数:19,代码来源:BmLitJsonReader.cs


示例11: ReadZenSettings

        private static ZenSettings ReadZenSettings(JsonReader reader)
        {
            ZenSettings settings = new ZenSettings();
            Type objType = settings.GetType();

            reader.Read();
            if (reader.Token != JsonToken.ObjectStart)
                return null;

            string currentProp = null;
            while (reader.Read())
            {
                if (reader.Token == JsonToken.ObjectEnd) break;
                if (reader.Token == JsonToken.PropertyName)
                    currentProp = reader.Value.ToString();
                else if (reader.Token == JsonToken.ObjectStart)
                {
                    if (currentProp == "variables") settings.variables = ReadHashtable(reader);
                    else settings.langs.Add(currentProp, ReadZenLang(reader));
                }
            }

            foreach (ZenLang lang in settings.langs.Values)
            {
                if (lang.extends != null && settings.langs.ContainsKey(lang.extends))
                    ExtendLang(lang, settings.langs[lang.extends]);
            }

            if (!settings.langs.ContainsKey("xml"))
            {
                ZenLang xlang = new ZenLang();
                xlang.abbreviations = new Hashtable();
                xlang.element_types = new ZenElementTypes(null);
                xlang.filters = "xml, xsl";
                xlang.snippets = new Hashtable();
                settings.langs.Add("xml", xlang);
            }

            settings.variables["child"] = "";
            return settings;
        }
开发者ID:heon21st,项目名称:flashdevelop,代码行数:41,代码来源:ZenCoding.cs


示例12: ReadObject

        public static void ReadObject(JsonReader reader, object context, BeginObjectDelegate begin, ParserDelegate parser, EndObjectDelegate end)
        {
            System.Diagnostics.Debug.Assert(reader.Token == JsonToken.ObjectStart);

            if (begin != null)
            {
                begin(context);
            }

            // parse the properties
            reader.Read();
            while (reader.Token != JsonToken.ObjectEnd)
            {
                parser(reader, context);
                reader.Read();
            }

            if (end != null)
            {
                end(context);
            }
        }
开发者ID:RELO4D3D,项目名称:sdk-dist,代码行数:22,代码来源:JsonUtil.cs


示例13: Reader

 private Reader(JsonReader json, string bundlePath, bool createdForThisInstance)
 {
     if (json == null)
     {
         throw new ArgumentNullException("json");
     }
     this.json = json;
     this.disposesTextReader = createdForThisInstance;
     this.prefix = bundlePath;
     if (!string.IsNullOrEmpty(this.prefix))
     {
         char chr = this.prefix[this.prefix.Length - 1];
         if (chr != '/' && chr != '\\')
         {
             this.prefix = string.Concat(this.prefix, "/");
         }
     }
     else
     {
         this.prefix = string.Empty;
     }
 }
开发者ID:HexHash,项目名称:LegacyRust,代码行数:22,代码来源:Reader.cs


示例14: Run

 private void Run()
 {
     using (StreamReader sr = new StreamReader(path.Path))
     {
         string raw = sr.ReadToEnd();
         sr.Close();
         JsonReader reader = new JsonReader(raw);
         try
         {
             if (reader.Read() && reader.Token == JsonToken.ObjectStart)
             {
                 files = new Dictionary<string, FileModel>();
                 BuildModel(reader);
                 path.SetFiles(files);
             }
         }
         catch (Exception ex)
         {
             TraceManager.AddAsync(ex.Message);
         }
     }
 }
开发者ID:Neverbirth,项目名称:flashdevelop,代码行数:22,代码来源:LibParser.cs


示例15: JsonWebTokenHeader

        public JsonWebTokenHeader(string originalData)
        {
            _originalData = originalData;
            var reader = new JsonReader(originalData.Base64UrlDecode(Encoding.UTF8));
            while (reader.Read())
            {
                if (reader.Token == JsonToken.PropertyName)
                {
                    switch (reader.Value.ToString())
                    {
                        case "alg":
                            reader.Read();
                            SetAlgorithm((string)reader.Value);
                            break;
                        case "kid":
                            reader.Read();
                            KeyId = (string)reader.Value;
                            break;
                        case "xdu":
                            reader.Read();
                            KeyFormat = KeyFormat.Rfc4050;
                            KeyUri = new Uri((string)reader.Value);
                            break;
                        case "jku":
                            reader.Read();
                            KeyFormat = KeyFormat.Json;
                            KeyUri = new Uri((string)reader.Value);
                            break;
                        case "xku":
                            reader.Read();
                            KeyFormat = KeyFormat.X509;
                            KeyUri = new Uri((string)reader.Value);
                            break;
                    }
                }

            }
        }
开发者ID:holytshirt,项目名称:Jwt4Net,代码行数:38,代码来源:JsonWebTokenHeader.cs


示例16: JsonKeyControlLoader

 public JsonKeyControlLoader(JsonReader reader)
 {
     dummyKeyControl = new DummyKeyControl();
     JsonMapper jsonMapper = new JsonMapper();
     while (reader.Read())
     {
         if (reader.Token == JsonToken.ObjectEnd)
         {
             break;
         }
         if (reader.Token == JsonToken.PropertyName)
         {
             switch (reader.Value as string)
             {
                 case "walkKeyBinding":
                     dummyKeyControl.walkKeyBinding = jsonMapper.ToObject<Dictionary<string, string>>(reader);
                     break;
                 case "layBombKey":
                     dummyKeyControl.layBombKey = jsonMapper.ToObject<string>(reader);
                     break;
             }
         }
     }
 }
开发者ID:NCCUCS-Windows-Programming,项目名称:Little-Bomber-King,代码行数:24,代码来源:JsonKeyControlLoader.cs


示例17: ReadArray

        public static void ReadArray(JsonReader reader, object context, BeginObjectDelegate begin, ParserDelegate parser, EndObjectDelegate end)
        {
            System.Diagnostics.Debug.Assert(reader.Token == JsonToken.ArrayStart);

            // parse the elements
            reader.Read();
            while (reader.Token != JsonToken.ArrayEnd)
            {
                if (reader.Token == JsonToken.ObjectStart)
                {
                    ReadObject(reader, context, begin, parser, end);
                }
                else if (reader.Token == JsonToken.ArrayStart)
                {
                    ReadArray(reader, context, parser);
                }
                else
                {
                    parser(reader, context);
                }

                reader.Read();
            }
        }
开发者ID:RELO4D3D,项目名称:sdk-dist,代码行数:24,代码来源:JsonUtil.cs


示例18: ReadJsonRpcData

 public static IDictionary<String, object> ReadJsonRpcData(Stream inputStream)
 {
     IDictionary<string, object> data = new Dictionary<string, object>();
     using (StreamReader sr = new StreamReader(inputStream))
     {
         JsonReader reader = new JsonReader(sr);
         reader.Read();
         if (reader.Token != JsonToken.ObjectStart)
             throw new ParseException("Unexpected token read!");
         while (reader.Read())
         {
             if (reader.Token == JsonToken.ObjectEnd)
                 break;
             if (reader.Token != JsonToken.PropertyName)
                 throw new ParseException("Unexpected token read!");
             string field = (string)reader.Value;
             if (!reader.Read())
                 throw new ParseException("Unexpected end of stream!");
             switch (field)
             {
             case "id":
                 data["id"] = (string)reader.Value;
                 break;
             case "method":
                 data["method"] = (string)reader.Value;
                 break;
             case "params":
                 if (reader.Token == JsonToken.ObjectStart)
                 {
                     data["parameters"] = JSON.ReadObject(reader);
                 }
                 break;
             default:
                 break;
             }
         }
     }
     return data;
 }
开发者ID:rogerthat-platform,项目名称:rogerthat-api-dotnet,代码行数:39,代码来源:CallbackApi.cs


示例19: ReadAttributes

 private void ReadAttributes(JsonReader reader, MemberModel decl)
 {
     while (reader.Read())
     {
         if (reader.Token == JsonToken.ArrayEnd) break;
         if (reader.Token == JsonToken.String)
         {
             string val = reader.Value.ToString();
             switch (val)
             {
                 case "native": decl.Flags |= FlagType.Native; break;
                 case "static": decl.Flags |= FlagType.Static; break;
                 case "public": decl.Access |= Visibility.Public; break;
                 case "internal": decl.Access |= Visibility.Internal; break;
                 case "protected": decl.Access |= Visibility.Protected; break;
                 case "private": decl.Access |= Visibility.Private; break;
                 case "final": decl.Flags |= FlagType.Final; break;
                 case "operator": break;
                 case "supercall": break;
                 default: break;
             }
         }
     }
 }
开发者ID:Neverbirth,项目名称:flashdevelop,代码行数:24,代码来源:LibParser.cs


示例20: ReadParameter

        private MemberModel ReadParameter(JsonReader reader, MemberModel member)
        {
            MemberModel para = new MemberModel("???", null, FlagType.Variable | FlagType.ParameterVar, Visibility.Public);
            member.Parameters.Add(para);

            string prop = null;
            bool isRest = false;
            while (reader.Read())
            {
                if (reader.Token == JsonToken.ObjectEnd) break;
                if (reader.Token == JsonToken.PropertyName) prop = reader.Value.ToString();
                else if (reader.Token == JsonToken.String)
                {
                    string val = reader.Value.ToString();
                    switch (prop)
                    {
                        case "hasdefault": para.Value = "?"; break; // TODO "hasdefault" is that used?
                        case "isvarargs": isRest = true; break;  // TODO "isvarargs" is that used?
                        case "name": para.Name = val; break;
                        case "type": if (para.Type == null) para.Type = CleanType(val); break;
                    }
                }
                else if (reader.Token == JsonToken.ObjectStart)
                {
                    switch (prop)
                    {
                        case "templatetypes": ReadTemplateTypes(reader, para); break;
                        default: reader.SkipObject(); break;
                    }
                }
            }
            if (isRest) para.Type = "..." + para.Type;
            return para;
        }
开发者ID:Neverbirth,项目名称:flashdevelop,代码行数:34,代码来源:LibParser.cs



注:本文中的LitJson.JsonReader类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# LitJson.JsonWriter类代码示例发布时间:2022-05-26
下一篇:
C# LitJson.JsonData类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap