C#反序列化Json串的问题
"port_list": {
"5985": {
"structinfo": "",
"protocol": "http",
"dbs": {
"DbSize": 0,
"Count": 0,
"Records": 0
},
"port": "5985",
"versions": [
"Microsoft-HTTPAPI : 2.0"
],
"ip": "10.122.5.154",
},
"135": {
"structinfo": "",
"protocol": "decrpc",
"dbs": {
"DbSize": 0,
"Count": 0,
"Records": 0
},
"port": "135",
"ip": "10.122.5.154",
"banner": "",
"time": "2019-05-14 20:50:09 +0800",
"port_state": "open",
"status": "success"
},
"137": {
"structinfo": "",
"netbios_name": "WIN-9PBV4405K7V",
"protocol": "netbios",
"dbs": {
"DbSize": 0,
"Count": 0,
"Records": 0
},
"port": "137",
"ip": "10.122.5.154",
"banner": "",
"time": "2019-05-14 20:25:35 +0800",
"port_state": "open",
"mac": "6c:0b:84:b8:14:31",
"status": "success"
},
"3389": {
"structinfo": "",
"protocol": "rdp",
"dbs": {
"DbSize": 0,
"Count": 0,
"Records": 0
},
"port": "3389",
"ip": "10.122.5.154",
"banner": "",
"time": "2019-05-14 20:40:56 +0800",
"port_state": "open",
"status": "success"
}
}
请教,这样的Json串,用C#反序列化,对于结构均相同,只名称不同的每个端口,应该如何声明同一个类,能把所有端口的Json串都反序列化出来。
"5985": {
"structinfo": "",
"protocol": "http",
"dbs": {
"DbSize": 0,
"Count": 0,
"Records": 0
},
"port": "5985",
"versions": [
"Microsoft-HTTPAPI : 2.0"
],
"ip": "10.122.5.154",
},
"135": {
"structinfo": "",
"protocol": "decrpc",
"dbs": {
"DbSize": 0,
"Count": 0,
"Records": 0
},
"port": "135",
"ip": "10.122.5.154",
"banner": "",
"time": "2019-05-14 20:50:09 +0800",
"port_state": "open",
"status": "success"
},
"137": {
"structinfo": "",
"netbios_name": "WIN-9PBV4405K7V",
"protocol": "netbios",
"dbs": {
"DbSize": 0,
"Count": 0,
"Records": 0
},
"port": "137",
"ip": "10.122.5.154",
"banner": "",
"time": "2019-05-14 20:25:35 +0800",
"port_state": "open",
"mac": "6c:0b:84:b8:14:31",
"status": "success"
},
"3389": {
"structinfo": "",
"protocol": "rdp",
"dbs": {
"DbSize": 0,
"Count": 0,
"Records": 0
},
"port": "3389",
"ip": "10.122.5.154",
"banner": "",
"time": "2019-05-14 20:40:56 +0800",
"port_state": "open",
"status": "success"
}
}
请教,这样的Json串,用C#反序列化,对于结构均相同,只名称不同的每个端口,应该如何声明同一个类,能把所有端口的Json串都反序列化出来。
...全文
相关推荐
Newtonsoft.Json-3.5.6
**动态对象**:支持将JSON串反序列化为动态对象,便于在运行时操作JSON数据。6.
将List对象列表转换成JSON格式的类.docx
JSON序列化和反序列化支持,包括处理复杂类型、嵌套结构、枚举、日期时间等,同时也能自动处理特殊字符转义等问题。
C# 后台序列化Json序列、反序列化Json序列(三种方法)
在.NET开发中,C#语言提供了多种方式来处理JSON序列化和反序列化,这对于数据交换和存储至关重要。
C#实现JSON字符串序列化与反序列化的方法
本文将详细讲解如何使用C#实现JSON字符串的序列化和反序列化。首先,我们要了解序列化和反序列化的概念。
C#实现的json序列化和反序列化代码实例
在C#中,有多种方式来实现JSON序列化和反序列化,本文将介绍两种主要的方法。


