我正在尝试将字符串反序列化为具有以下结构的类:
// this is my json
{
"MethodName":"PRC_SET_COMMISSION_STATIC",
"Input":"{"reqType":"U","sapId":17000100,"offerType":5,"commissionRate":4,"accountNo":null,"fromDate":"2022-05-29T00:00:00","toDate":"2029-05-29T00:00:00","userId":"13601360"}"}
这是我的类,我想得到这些值:
public class ProcessRequestRequestModelCl :AuthenticationModelCl
{
public string MethodName { get; set; }
public string Input { get; set; }
}
所以我要做的是这样的:
ProcessRequestRequestModelCl RequestModel = System.Text.Json.JsonSerializer.Deserialize<ProcessRequestRequestModelCl>(ParameterStr);
但我得到了这个错误:* *“r”在值后无效。应为“,”、“}”或“]”**问题与"Input":"{"reqType":"U","sapId":17000100,"offerType":5,"commissionRate":4,"accountNo":null,"fromDate":"2022-05-29T00:00:00","toDate":"2029-05-29T00:00:00","userId":"13601360"}"
有关。我想知道如何将json作为字符串传递给输入值。
1条答案
按热度按时间osh3o9ms1#
如果你真的需要内部json作为一个字符串,你需要如下转义引号: