' r'值之后是无效的。预期的是,要么是,','}' or&']'
我试图通过此结构将字符串供应到类:
// 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,“ coundactno”:null,“ fromdate”:“” 2022-05-29T00:00:00“,” todate“:” 2029-05-29T00:00:00:00:00:00:00:“ userId”:“ 13601360”}“}”
。我想知道我应该如何将JSON作为字符串传递给输入值。
I am trying to Deserialize string to class with this structure:
// 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"}"}
And this is my class which I want to get this values:
public class ProcessRequestRequestModelCl :AuthenticationModelCl
{
public string MethodName { get; set; }
public string Input { get; set; }
}
So what I do to achieve this is something like this:
ProcessRequestRequestModelCl RequestModel = System.Text.Json.JsonSerializer.Deserialize<ProcessRequestRequestModelCl>(ParameterStr);
but I get this error: 'r' is invalid after a value. Expected either ',', '}', or ']'
problem is something with "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"}"
. I was wondering how should I Pass json as string to input value.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您确实需要将内部的json作为字符串,则需要逃脱这样的报价:
If you really need to have the inner json as a string, you need to escape the quotes like this: