I have a JSON data to post to http, this JSON data has a var named params:
{
"method": "...",
"params": [ ... ],
"session": "...",
"id": 1
}
I want to link every request and response to a class in my Models. How can I either use the name params for the attribute or make the attribute name change as I serialize my class to JSON format? I am using ASP.NET MVC 4 and JSON.NET framework on visual studio 2013 Ultimate edition.
A property named params
(or any other keyword) can be used in C# classes as long as you escape the name using the @ prefix:
class MyClass
{
public string method { get; set; }
public Whatever @params { get; set; }
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With