36

I have an object that is created by Newtonsoft's JSON serializer. I need to get the JSON string that was used to create the object. How do I serialize the object into a simple JSON string?

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Ian Vink
  • 66,960
  • 104
  • 341
  • 555

1 Answers1

82

Try this:

public string jsonOut()
{
    // Returns JSON string.
    return JsonConvert.SerializeObject(this);       
}
Sheena
  • 15,590
  • 14
  • 75
  • 113