Avatar of Jesper Christensen
Jesper Christensen
 asked on

Make class to jSon string

My json string should look like this:
{
"plan":"test",
"name":"test",
"createuser": {
"username":"test",
"usermail":"test",
}
}

How does I build the user class so I can make a json string.
var user = new
{
      plan = "test",
      name= "test",
      createuser ???? {}
};
var jSon = JsonConvert.SerializeObject(user);
C#JSON

Avatar of undefined
Last Comment
Nitin Sontakke

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Nitin Sontakke

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Jesper Christensen

ASKER
Thank you! Which method would you perfer?

your first example, or your last?
Nitin Sontakke

First, of course, as I already mentioned in my original comment. Frankly, never used second, so I don't even know if it works with deserialisation.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck