nEkis
nEkis

Reputation: 340

Params keyword in JSON object

I am creating a JSON object in code. But the JSON contains property params, so when I try to create object like this:

using Newtonsoft.Json.Linq;

JObject json = JObject.FromObject(new
{
   jsonrpc = "2.0",
   method = "user.login",
   params = new
   {
      user = "user",
      password = "password"
   },
   id = 1
});

I get an error because VS thinks its params the keyword. Is there way how to create object like this or somehow use params without using params?

Upvotes: 2

Views: 1725

Answers (1)

hpfs
hpfs

Reputation: 506

Use @params so you can escape special keywords

Upvotes: 8

Related Questions