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

C# JArray类代码示例

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

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



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

示例1: InternalCall

 private static JObject InternalCall(string method, JArray _params)
 {
     switch (method)
     {
         case "getbestblockhash":
             return Blockchain.Default.CurrentBlockHash.ToString();
         case "getblock":
             {
                 UInt256 hash = UInt256.Parse(_params[0].AsString());
                 Block block = Blockchain.Default.GetBlock(hash);
                 if (block == null)
                     throw new RpcException(-100, "Unknown block");
                 return block.ToJson();
             }
         case "getblockcount":
             return Blockchain.Default.Height + 1;
         case "getblockhash":
             {
                 uint height = (uint)_params[0].AsNumber();
                 return Blockchain.Default.GetBlockHash(height).ToString();
             }
         case "getrawtransaction":
             {
                 UInt256 hash = UInt256.Parse(_params[0].AsString());
                 Transaction tx = Blockchain.Default.GetTransaction(hash);
                 if (tx == null)
                     throw new RpcException(-101, "Unknown transaction");
                 return tx.ToJson();
             }
         default:
             throw new RpcException(-32601, "Method not found");
     }
 }
开发者ID:qlw,项目名称:AntShares,代码行数:33,代码来源:RpcServer.cs


示例2: AddToSelf

    public void AddToSelf()
    {
      JArray a = new JArray();
      a.Add(a);

      Assert.IsFalse(ReferenceEquals(a[0], a));
    }
开发者ID:royra,项目名称:ravendb,代码行数:7,代码来源:JArrayTests.cs


示例3: ToListOfListOfCoordinates

 public static List<List<Coordinate[]>> ToListOfListOfCoordinates(JArray array)
 {
     List<List<Coordinate[]>> c = new List<List<Coordinate[]>>();
         for (int i = 0; i < array.Count; i++)
             c.Add(ToListOfCoordinates((JArray)array[i]));
         return c;
 }
开发者ID:j2jensen,项目名称:ravendb,代码行数:7,代码来源:GeometryConverter.cs


示例4: vaildData

        public static void vaildData()
        {
            JArray ja = (JArray)JsonConvert.DeserializeObject(File.ReadAllText(@"input/mergeresult_final.json"));
            JArray jaTemp = new JArray();
            DirectoryInfo dirInfo = new DirectoryInfo(@"C:\Users\GIS-615\SkyDrive\论文&项目\研究生毕业论文\数据\GetPoiTimeLineWithAzure\原始数据");
            foreach (JObject jo in ja)
            {
                int count = 0;
                foreach (FileInfo file in dirInfo.GetFiles())
                {
                    string filename = file.Name.Substring(0, file.Name.Length - 5);
                    if (jo["poiid"].ToString().Equals(filename))
                    {
                        count++;
                        break;
                    }
                }
                if (count == 0)
                {
                    jaTemp.Add(jo);
                }
            }

            File.WriteAllText(@"output//nullData.json", jaTemp.ToString());
        }
开发者ID:siszoey,项目名称:getPoisFromWeibo,代码行数:25,代码来源:Program.cs


示例5: Clear

    public void Clear()
    {
      JArray a = new JArray {1};
      Assert.AreEqual(1, a.Count);

      a.Clear();
      Assert.AreEqual(0, a.Count);
    }
开发者ID:royra,项目名称:ravendb,代码行数:8,代码来源:JArrayTests.cs


示例6: WriteJson

    public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
    {
      ConverterPrecedenceClass c = (ConverterPrecedenceClass)value;

      JToken j = new JArray(ConverterType, c.TestValue);

      j.WriteTo(writer);
    }
开发者ID:royra,项目名称:ravendb,代码行数:8,代码来源:ConverterPrecedenceClassConverter.cs


示例7: ToCoordinates

 public static Coordinate[] ToCoordinates(JArray array)
 {
     Coordinate[] c = new Coordinate[array.Count];
         for (int i = 0; i < array.Count; i++)
         {
             c[i] = ToCoordinate((JArray) array[i]);
         }
         return c;
 }
开发者ID:j2jensen,项目名称:ravendb,代码行数:9,代码来源:GeometryConverter.cs


示例8: ForEach

    public void ForEach()
    {
      JArray items = new JArray(new JObject(new JProperty("name", "value!")));

      foreach (JObject friend in items)
      {
        Console.WriteLine(friend);
      }
    }
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:9,代码来源:LinqToJsonTest.cs


示例9: JArrayDictionary

        public void JArrayDictionary()
        {
            Dictionary<JToken, int> dic = new Dictionary<JToken, int>(JToken.EqualityComparer);
            JArray v11 = new JArray();
            JArray v12 = new JArray();

            dic[v11] = 1;
            dic[v12] += 1;
            Assert.AreEqual(2, dic[v11]);
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:10,代码来源:JTokenEqualityComparerTests.cs


示例10: MergeJArray

 public static JArray MergeJArray(JArray arr1, JArray arr2)
 {
     if (arr2.Count > 0)
     {
         foreach (JObject jo in arr2)
         {
             arr1.Add(jo);
         }
     }
     return arr1;
 }
开发者ID:siszoey,项目名称:getPoisFromWeibo,代码行数:11,代码来源:Program.cs


示例11: Contains

    public void Contains()
    {
      JValue v = new JValue(1);

      JArray a = new JArray {v};

      Assert.AreEqual(false, a.Contains(new JValue(2)));
      Assert.AreEqual(false, a.Contains(new JValue(1)));
      Assert.AreEqual(false, a.Contains(null));
      Assert.AreEqual(true, a.Contains(v));
    }
开发者ID:royra,项目名称:ravendb,代码行数:11,代码来源:JArrayTests.cs


示例12: Manual

    public void Manual()
    {
      JArray array = new JArray();
      JValue text = new JValue("Manual text");
      JValue date = new JValue(new DateTime(2000, 5, 23));

      array.Add(text);
      array.Add(date);

      string json = array.ToString();
      // [
      //   "Manual text",
      //   "\/Date(958996800000+1200)\/"
      // ]
    }
开发者ID:925coder,项目名称:ravendb,代码行数:15,代码来源:LinqToJsonTest.cs


示例13: Respond

		public override void Respond(IHttpContext context)
		{
			var dir = ResourceStore.Configuration.PluginsDirectory;
			if (Directory.Exists(dir))
			{
				var paths = from path in Directory.GetFiles(dir, "*.xap", SearchOption.AllDirectories)
				            select path.Replace(dir, string.Empty).Replace(".xap", string.Empty);

				var xaps = new JArray(paths);
				context.WriteJson(xaps);
			}
			else
			{
				context.WriteJson(new JArray());
			}
		}
开发者ID:royra,项目名称:ravendb,代码行数:16,代码来源:SilverlightPlugins.cs


示例14: ToJContainer

        public static JContainer ToJContainer(this ICollection target)
        {
            if (target != null)
            {
                var jobjarray = new JArray();

                foreach (var item in target)
                {
                    jobjarray.Add(item.ToJContainer());
                }

                return jobjarray;
            }

            return null;
        }
开发者ID:MGramolini,项目名称:vodca,代码行数:16,代码来源:Extensions.ToJContainer.cs


示例15: Example

        public void Example()
        {
            #region Usage
            IList<BlogPost> blogPosts = new List<BlogPost>
            {
                new BlogPost
                {
                    Title = "Json.NET is awesome!",
                    AuthorName = "James Newton-King",
                    AuthorTwitter = "JamesNK",
                    PostedDate = new DateTime(2013, 1, 23, 19, 30, 0),
                    Body = @"<h3>Title!</h3>
                       <p>Content!</p>"
                }
            };

            JArray blogPostsArray = new JArray(
                blogPosts.Select(p => new JObject
                {
                    { "Title", p.Title },
                    {
                        "Author", new JObject
                        {
                            { "Name", p.AuthorName },
                            { "Twitter", p.AuthorTwitter }
                        }
                    },
                    { "Date", p.PostedDate },
                    { "BodyHtml", HttpUtility.HtmlEncode(p.Body) },
                })
                );

            Console.WriteLine(blogPostsArray.ToString());
            // [
            //   {
            //     "Title": "Json.NET is awesome!",
            //     "Author": {
            //       "Name": "James Newton-King",
            //       "Twitter": "JamesNK"
            //     },
            //     "Date": "2013-01-23T19:30:00",
            //     "BodyHtml": "&lt;h3&gt;Title!&lt;/h3&gt;\r\n&lt;p&gt;Content!&lt;/p&gt;"
            //   }
            // ]
            #endregion
        }
开发者ID:extesla,项目名称:OpenGamingLibrary,代码行数:46,代码来源:SerializeWithLinq.cs


示例16: GetUser

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static string GetUser(string query_loginName, string query_username)
        {
            JArray ja = new JArray();

            try
            {
                using (venuesEntities db = new venuesEntities())
                {

                    string strSql = "SELECT su.User_Id,su.User_LoginName,su.User_Name,su.User_Password,sd.DA_Name,sd.DA_Code,su.User_TypeId FROM tbl_sys_user AS su LEFT JOIN tbl_sys_dictionary AS sd ON su.User_TypeId=sd.DA_Id where 1=1 ";
                    if (query_loginName != "")
                    {
                        strSql += " and su.User_LoginName='" + query_loginName + "'";
                    }
                    else if (query_username != "")
                    {
                        strSql += " and su.User_Name='" + query_username + "'";
                    }

                    ObjectQuery<DbDataRecord> results = db.CreateQuery<DbDataRecord>(strSql);

                    foreach (var item in results)
                    {
                        ja.Add(
                            new JObject(
                                new JProperty("User_Id", item["User_Id"].ToString()),
                                new JProperty("User_LoginName", item["User_LoginName"].ToString()),
                                new JProperty("User_Name", item["User_Name"].ToString()),
                                new JProperty("User_Password", item["User_Password"].ToString()),
                                new JProperty("DA_Name", item["DA_Name"].ToString()),
                                new JProperty("User_TypeId", item["User_TypeId"].ToString()),
                                new JProperty("DA_Code", item["DA_Code"].ToString())
                                )
                            );
                    };
                }
            }
            catch (Exception e)
            {
                addLog(KeyManager.LogTypeId_Error, KeyManager.CUR_USERID, KeyManager.MENUS.Menu_SystemUsersManager, "查询用户列表,User_LoginName=" + query_loginName + ",User_Name=" + query_username + ",错误信息:" + e.Message);
            }
            addLog(KeyManager.LogTypeId_Option, KeyManager.CUR_USERID, KeyManager.MENUS.Menu_SystemUsersManager, "查询用户列表,User_LoginName=" + query_loginName + ",User_Name=" + query_username);
            return ja.ToString();
        }
开发者ID:zyyecho,项目名称:venues,代码行数:48,代码来源:User_Functions.cs


示例17: Example

        public void Example()
        {
            #region Usage
            JArray array = new JArray();
            array.Add("Manual text");
            array.Add(new DateTime(2000, 5, 23));

            JObject o = new JObject();
            o["MyArray"] = array;

            string json = o.ToString();
            // {
            //   "MyArray": [
            //     "Manual text",
            //     "2000-05-23T00:00:00"
            //   ]
            // }
            #endregion
        }
开发者ID:extesla,项目名称:OpenGamingLibrary,代码行数:19,代码来源:CreateJsonManually.cs


示例18: CnvJsonDataToList

            /// <summary>
            ///     Convert JSON Data
            /// </summary>
            /// <param name="jsondata">JSON Object</param>
            /// <returns>MDR Text Data</returns>
            /// <remarks></remarks>
            public static List<DeviceEventMdrTextData> CnvJsonDataToList(JArray jsondata)
            {
                var result = new List<DeviceEventMdrTextData>();

                foreach (var obj in jsondata)
                {
                    var tmp = new DeviceEventMdrTextData();

                    tmp.PatientSequenceNumber = Utilities.GetJTokenString(obj, "patient_sequence_number");
                    tmp.TextTypeCode = Utilities.GetJTokenString(obj, "text_type_code");
                    tmp.Text = Utilities.GetJTokenString(obj, "text");
                    tmp.MdrTextKey = Utilities.GetJTokenString(obj, "mdr_text_key");
                    tmp.DateReceived = Utilities.GetJTokenString(obj, "date_received");

                    result.Add(tmp);
                }

                return result;
            }
开发者ID:Steve-Frost,项目名称:Total-Recall-DEV,代码行数:25,代码来源:DeviceEventMdrTextData.cs


示例19: NewInstance

        /// <summary>
        /// Static function to return instance of the union schema
        /// </summary>
        /// <param name="jarr">JSON object for the union schema</param>
        /// <param name="names">list of named schemas already read</param>
        /// <param name="encspace">enclosing namespace of the schema</param>
        /// <returns>new UnionSchema object</returns>
        internal static UnionSchema NewInstance(JArray jarr, PropertyMap props, SchemaNames names, string encspace)
        {
            List<Schema> schemas = new List<Schema>();
            IDictionary<string, string> uniqueSchemas = new Dictionary<string, string>();

            foreach (JToken jvalue in jarr)
            {
                Schema unionType = Schema.ParseJson(jvalue, names, encspace);
                if (null == unionType)
                    throw new SchemaParseException("Invalid JSON in union" + jvalue.ToString());

                string name = unionType.Name;
                if (uniqueSchemas.ContainsKey(name))
                    throw new SchemaParseException("Duplicate type in union: " + name);

                uniqueSchemas.Add(name, name);
                schemas.Add(unionType);
            }

            return new UnionSchema(schemas, props);
        }
开发者ID:sdgdsffdsfff,项目名称:hermes.net,代码行数:28,代码来源:UnionSchema.cs


示例20: DiffCategories

 private static void DiffCategories()
 {
     //type1
     int[] typeArray = new int[]{
         33,
         116,179,180,182,183,
         184,185,186,187,188,
         195,196,197,198,
         199,200,201,202,203,
         204,205,206,207,208,
         234,239,240,243,244,
         245,246,607
     };
     //去掉252,254,20,156,219,45,52,671,678,189, 220,221,222,223,224,
     //225,226,227,228,229,230,231,232,233,235,236,237,238,250,604,677,627,628
     List<int> typeList = new List<int>(typeArray);
     JArray ja = (JArray)JsonConvert.DeserializeObject(File.ReadAllText(@"../../output/type1/typetrue.json"));
     //foreach (int num in typeList)
     //{
     int num = 252;
         string path = @"../../output/45/";
         //if (!Directory.Exists(path))
         //{
         //    Directory.CreateDirectory(path);
         //}
         JArray jaType = new JArray();
         foreach (JObject jo in ja)
         {
             if (Int32.Parse(jo["category"].ToString()) == num)
             {
                 jaType.Add(jo);
                 Console.WriteLine("jaType :" + DateTime.Now.ToLocalTime().ToString() + ";" + jo["title"].ToString() + ";" + jo["poiid"].ToString());
                 streamWriter.WriteLine("jaType :" + DateTime.Now.ToLocalTime().ToString() + ";" + jo["title"].ToString() + ";" + jo["poiid"].ToString());
             }
             Console.WriteLine("jaType:" + DateTime.Now.ToLocalTime().ToString() + ";" + jaType.Count.ToString());
             streamWriter.WriteLine("jaType:" + DateTime.Now.ToLocalTime().ToString() + ";" + jaType.Count.ToString());
             File.WriteAllText(path + "/" + num + ".json", jaType.ToString());
         }
     //}
 }
开发者ID:siszoey,项目名称:getPoisFromWeibo,代码行数:40,代码来源:Program.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# JBLOCK类代码示例发布时间:2022-05-24
下一篇:
C# Itop类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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