[英]Read data from a JSON file
I have a JSON file out of the custom JSON pattern.我有一个来自自定义 JSON 模式的 JSON 文件。 And I need get this string values with array, list or anything.我需要用数组、列表或任何东西来获取这个字符串值。
example.json:示例.json:
[
["fight", "gunshot", "fleeing"],
["gunshot", "falling", "fleeing"]
]
If you use @Jimi option like that如果你像这样使用@Jimi 选项
First第一的
using Newtonsoft.Json;
using System.Collections.Generic;
Then然后
string myJsonString = @"[['fight', 'gunshot', 'fleeing'], ['gunshot', 'falling', 'fleeing']]";
List<List<string>> items = JsonConvert.DeserializeObject<List<List<string>>>(myJsonString );
Console.Write(items[0][0]);
foreach (var item in items)
{
foreach(var subitem in item){
Console.WriteLine(subitem);
}
}
also here is working version this code maybe you can create a simular stack app then share with us.这里也是这个代码的工作版本,也许您可以创建一个模拟堆栈应用程序然后与我们分享。 https://dotnetfiddle.net/oKUUxa https://dotnetfiddle.net/oKUUxa
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.