我不知道如何将 Json 输入转换为 ac# 模型。
这是我的控制器获得的 Json 示例:
[{"name":"StartDate",
"value":"0",
"Processors":[[{"processor":{"ProcessorName":"searchAndReplace","ProcessorParameters":[{"ParameterName":"toto"},{"ParameterName":"taa"}]}},
{"processor":{"ProcessorName":"searchAndReplace","ProcessorParameters":[{"ParameterName":"toto"},{"ParameterName":"tuuut"}]}}]]},
{"name":"EndDate","value":"1","Processors":[[]]},
{"name":"Country","value":"2","Processors":[[]]}]
这是我的控制器的签名:
public JsonResult SendMapping(List<Mapping> MyMappings)
这是我的课程“映射”:
public class Mapping
{
public string Value { get; set; }
public string Name { get; set; }
public List<Processor> Processors { get; set; }
}
然后是我的“处理器模型”
public enum ProcessorNames { SearchAndReplace }
public class ProcessorModel
{
public Processor processor;
}
public class Processor
{
public ProcessorNames ProcessorName;
public List<Parameter> ProcessorParameters;
}
public class Parameter
{
public List<string> ParameterName;
}
到目前为止,我可以获得所有的name和value。我还可以检索第一个ProcessorName,但不能检索它的参数,也不能检索其他ProcessorNames