Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

'r' is invalid after a value. Expected either ',', '}', or ']'

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

>Solution :

If you really need to have the inner json as a string, you need to escape the qutoes like this:

{
    "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\"}"
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading