C# MVC5 JSON解析
我有来自第三方系统的JSON(因此我无法更改JSON)。我试图将其解析为MethodItems列表,但我的C# MVC5 JSON解析,c#,json,asp.net-mvc,C#,Json,Asp.net Mvc,我有来自第三方系统的JSON(因此我无法更改JSON)。我试图将其解析为MethodItems列表,但我的Items集合总是null。我在控制器操作中使用内置的MVC5JSON反序列化器。我错过了什么 { "Method": { "name": "GetItems", "items": { "Item 1": { "name": "myItem", "value": "toot
Items
集合总是null
。我在控制器操作中使用内置的MVC5JSON反序列化器。我错过了什么
{ "Method": {
"name": "GetItems",
"items": {
"Item 1": {
"name": "myItem",
"value": "toothbrush"
},
"Item 2": {
"name": "my item 2",
"value": "razor"
}
}
}
C#这里的对象
public class RequestRoot {
public Method Method { get; set; }
}
public class Method {
public string Name { get; set; }
public MethodItem[] Items { get; set; }
}
public class MethodItem {
public string name { get; set; }
public string value { get; set; }
}
项目
应视为字典,请尝试以下方法:
public class Method
{
public string name { get; set; }
public Dictionary<string,MethodItem> items { get; set; }
}
public class MethodItem
{
public string name { get; set; }
public string value { get; set; }
}
公共类方法
{
公共字符串名称{get;set;}
公共字典项{get;set;}
}
公共类方法项
{
公共字符串名称{get;set;}
公共字符串值{get;set;}
}
项目应视为字典,请尝试以下方法:
public class Method
{
public string name { get; set; }
public Dictionary<string,MethodItem> items { get; set; }
}
public class MethodItem
{
public string name { get; set; }
public string value { get; set; }
}
公共类方法
{
公共字符串名称{get;set;}
公共字典项{get;set;}
}
公共类方法项
{
公共字符串名称{get;set;}
公共字符串值{get;set;}
}
项目应视为字典,请尝试以下方法:
public class Method
{
public string name { get; set; }
public Dictionary<string,MethodItem> items { get; set; }
}
public class MethodItem
{
public string name { get; set; }
public string value { get; set; }
}
公共类方法
{
公共字符串名称{get;set;}
公共字典项{get;set;}
}
公共类方法项
{
公共字符串名称{get;set;}
公共字符串值{get;set;}
}
项目应视为字典,请尝试以下方法:
public class Method
{
public string name { get; set; }
public Dictionary<string,MethodItem> items { get; set; }
}
public class MethodItem
{
public string name { get; set; }
public string value { get; set; }
}
公共类方法
{
公共字符串名称{get;set;}
公共字典项{get;set;}
}
公共类方法项
{
公共字符串名称{get;set;}
公共字符串值{get;set;}
}
项
不是数组。它是两个具有相同属性名称的对象。它是一个可变长度tho。我可以重复很多。我可以做些什么来让它映射吗?items
不是数组。它是两个具有相同属性名称的对象。它是一个可变长度tho。我可以重复很多。我可以做些什么来让它映射吗?items
不是数组。它是两个具有相同属性名称的对象。它是一个可变长度tho。我可以重复很多。我可以做些什么来让它映射吗?items
不是数组。它是两个具有相同属性名称的对象。它是一个可变长度tho。我可以重复很多。我能做些什么把它放到地图上吗?