本文整理汇总了C#中JArray类的典型用法代码示例。如果您正苦于以下问题:C# JArray类的具体用法?C# JArray怎么用?C# JArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JArray类属于命名空间,在下文中一共展示了JArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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");
}
}
示例2: AddToSelf
public void AddToSelf()
{
JArray a = new JArray();
a.Add(a);
Assert.IsFalse(ReferenceEquals(a[0], a));
}
示例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;
}
示例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());
}
示例5: Clear
public void Clear()
{
JArray a = new JArray {1};
Assert.AreEqual(1, a.Count);
a.Clear();
Assert.AreEqual(0, a.Count);
}
示例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);
}
示例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;
}
示例8: ForEach
public void ForEach()
{
JArray items = new JArray(new JObject(new JProperty("name", "value!")));
foreach (JObject friend in items)
{
Console.WriteLine(friend);
}
}
示例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]);
}
示例10: MergeJArray
public static JArray MergeJArray(JArray arr1, JArray arr2)
{
if (arr2.Count > 0)
{
foreach (JObject jo in arr2)
{
arr1.Add(jo);
}
}
return arr1;
}
示例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));
}
示例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)\/"
// ]
}
示例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());
}
}
示例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;
}
示例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": "<h3>Title!</h3>\r\n<p>Content!</p>"
// }
// ]
#endregion
}