惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

MyScale Blog
MyScale Blog
爱范儿
爱范儿
The Register - Security
The Register - Security
小众软件
小众软件
D
DataBreaches.Net
雷峰网
雷峰网
S
Secure Thoughts
L
LINUX DO - 最新话题
M
MIT News - Artificial intelligence
Application and Cybersecurity Blog
Application and Cybersecurity Blog
罗磊的独立博客
F
Fortinet All Blogs
博客园 - 叶小钗
TaoSecurity Blog
TaoSecurity Blog
博客园 - Franky
aimingoo的专栏
aimingoo的专栏
S
SegmentFault 最新的问题
Hacker News: Ask HN
Hacker News: Ask HN
Help Net Security
Help Net Security
N
News and Events Feed by Topic
S
Security Affairs
The Last Watchdog
The Last Watchdog
Forbes - Security
Forbes - Security
S
Security @ Cisco Blogs
Latest news
Latest news
O
OpenAI News
N
Netflix TechBlog - Medium
云风的 BLOG
云风的 BLOG
Blog — PlanetScale
Blog — PlanetScale
Google Online Security Blog
Google Online Security Blog
S
Securelist
博客园 - 司徒正美
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
T
Threat Research - Cisco Blogs
C
CXSECURITY Database RSS Feed - CXSecurity.com
P
Palo Alto Networks Blog
T
The Blog of Author Tim Ferriss
Stack Overflow Blog
Stack Overflow Blog
I
InfoQ
阮一峰的网络日志
阮一峰的网络日志
AI
AI
SecWiki News
SecWiki News
G
GRAHAM CLULEY
Cloudbric
Cloudbric
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
L
LINUX DO - 热门话题
C
Cybersecurity and Infrastructure Security Agency CISA
B
Blog RSS Feed

博客园 - 威少小二orz

团结引擎抖音小游戏一定要手动填缓存资源域名 团结引擎+Addressable+Instant Game打包抖音小游戏 团结引擎发布抖音小游戏(十万个坑已踩完) 团结引擎发布小游戏区分不同平台 团结引擎发布小游戏与js版本SDK的互相调用 Unity发布京东小游戏 LayerMask的使用规范 Unity RectTransform中使用stretch模式时代码动态控制Left、Top、Right、Bottom Unity使用https请求握手失败的处理方案 【MAUI开发】一、初识MAUI Android中使用GSON解析JSON数据 游戏软著渠道的用户协议和隐私协议方案(启动显示方案) C#文件夹复制 C#在Json序列化中动态忽略某些属性或字段 安卓多个Activity大退时自动重启的问题处理 对于UniWebView这种组件违规获取信息的处理 TapTap实名认证-Android Unity使用Get和Post传递json数据并转换成class对象 Unity获取手机本地应用以及调起apk安装、启动app、安装完成回调 Unity接入穿山甲GroMore广告——重构偏2(Banner广告)
C#中接收到的Json数据中key为数字的问题处理
威少小二orz · 2023-02-24 · via 博客园 - 威少小二orz

本文使用的Json库为Newtonsoft.Json

接收到的json数据如下:

{"errcode":0,"errmsg":"","
data":{
"show_msg":1,
"show_errmsg":1,
"config":{"1":50,"2":1,"3":10,"4":1000,"5":100,"6":1,"7":500}}}

接收时使用的对象如下:

public class S_Common_Data<T>
{
    public int errcode = -1;
    public string errmsg;
    public T data;
}

public class S_Permission_Data
{
    public int show_msg;
    public int show_errmsg;
    public IDictionary<string, string> config;
}

序列化时的调用为:

S_Common_Data<S_Permission_Data> data = JsonConvert.DeserializeObject<S_Common_Data<S_Permission_Data>>(json);

即可将config里的纯数字key以字典的形式输出,当然如果可以保证一定是数字,也可以把key值用int类型来接收。