public static string Readjson(string key)
{
Assembly assembly = Assembly.GetExecutingAssembly();
String jsonfile = assembly.GetName().Name + ".Resources.JsonName.json";
Stream istr = assembly.GetManifestResourceStream(jsonfile);
using (StreamReader file = new StreamReader(istr))
{
using (JsonTextReader reader = new JsonTextReader(file))
{
JObject o = (JObject)JToken.ReadFrom(reader);
if (o[key] != null)
{
return o[key].ToString();
}
else { return ""; }
}
}
}
c#读取内嵌json资源并获取通过key获取value
最新推荐文章于 2024-09-03 09:04:15 发布