0

what is best way to serialize below string in c# and How will i handle c# keyword "this" in this case.

{
 this: 
  {
   appId: "asd123dasfkioj240234kfwoe90fjiwcsskjf0"
  }
}

Or

{
    "this":
    {
            "appId":"asd123dasfkioj240234kfwoe90fjiwcsskjf0"
    }
}
kumar chandraketu
  • 2,232
  • 2
  • 20
  • 25
  • 2
    Just define a property with `@`. For example `public MyType @this {get;set;}` – Aleks Andreev Oct 18 '18 at 19:19
  • Kumar you can use `[JsonProperty]` to solve your issue, check this answer: https://stackoverflow.com/a/24536739/558486 – Rui Jarimba Oct 18 '18 at 19:24
  • 1
    I think these are better duplicates: [How can I use a reserved keyword as an identifier in my JSON model class?](https://stackoverflow.com/q/16704733); [object to deserialize has a C# keyword](https://stackoverflow.com/q/23116995); [How can I use a keyword as a property name?](https://stackoverflow.com/q/4456505); [JSON: How to parse the JSON string which contains “object”:“page”](https://stackoverflow.com/q/38520406). All have answers that suggest using the "verbatim" operator `root.@this`. – dbc Oct 18 '18 at 19:27

0 Answers0