C# 解析 Json(Jason)数据
json
适用于现代 C++ 的 JSON。
项目地址:https://gitcode.com/gh_mirrors/js/json
免费下载资源
·
-
- //先在项目中添加System.Web.Extensions引用
- using System.Web.Script.Serialization;
- JavaScriptSerializer serializer = new JavaScriptSerializer();
- Dictionary<string, object> json = (Dictionary<string, object>)serializer.DeserializeObject(
- "{name: 'xrend', forum: 'c#'}");
- object value;
- if (json.TryGetValue("name", out value))
- Console.WriteLine(value);
这样,我们就可以把json数据解析读取了 简单吧 ~~
2013-10-15 修改,
看到自己之前写的这篇文章,简直删的心思都有了,太弱了,为了不把大家带到沟里,5年后的我用的 newtonsoft.json.dll这个第三方工具来解析的,两个方法就足够用了
public static T DeserializeObject<T>(string value)
{
if (!string.IsNullOrEmpty(value))
{
return Newtonsoft.Json.JsonConvert.DeserializeObject<T>(value);
}
else
{
return default(T);
}
}
public static string JsonSerializer(object obj)
{
IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd' 'HH':'mm':'ss";
return Newtonsoft.Json.JsonConvert.SerializeObject(obj,Newtonsoft.Json.Formatting.None,timeConverter);
}
由于自己解析的日期格式是 国际标准时间,带时区的,加上这个日期格式的转换,就可以解析自己想要的日期字符串了
GitHub 加速计划 / js / json
18
5
下载
适用于现代 C++ 的 JSON。
最近提交(Master分支:3 个月前 )
2134cb94
* change NLOHMANN_JSON_FROM_WITH_DEFAULT to let NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT work with an empty JSON instance
* fix ci_static_analysis_clang (ci_clang_tidy)
* change NLOHMANN_JSON_FROM_WITH_DEFAULT to let NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT work with an empty JSON instance 5 天前
6057b31d
* :wrench: overwork astyle call
* :wrench: overwork astyle call
* :wrench: overwork astyle call
* :wrench: overwork astyle call
* :wrench: overwork astyle call
* :wrench: overwork astyle call
* :wrench: overwork astyle call
* :wrench: overwork astyle call
* :wrench: overwork astyle call
* :wrench: overwork astyle call
* :wrench: overwork astyle call
* Use ubuntu-latest image to run Valgrind (#4575)
* :wrench: use Clang image to run valgrind
* :wrench: use Clang image to run valgrind
* :wrench: use Clang image to run valgrind
* :wrench: use Ubuntu image to run valgrind
* Use Clang image to run iwyu (#4574)
* :wrench: use Clang image to run iwyu
* :wrench: use Clang image to run iwyu
* :wrench: overwork astyle call
* :wrench: overwork astyle call
* :wrench: overwork astyle call
* :wrench: overwork astyle call
* :wrench: overwork astyle call
* :wrench: overwork astyle call
* :wrench: overwork astyle call
* :wrench: overwork astyle call
* :wrench: overwork astyle call
* :wrench: overwork astyle call
* :wrench: overwork astyle call
* :art: format code
* :hammer: clean up 6 天前
更多推荐
已为社区贡献2条内容
所有评论(0)