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?
Asked
Active
Viewed 4.7k times
1 Answers
82
Try this:
public string jsonOut()
{
// Returns JSON string.
return JsonConvert.SerializeObject(this);
}

Sergey Vyacheslavovich Brunov
- 17,291
- 7
- 48
- 81

Sheena
- 15,590
- 14
- 75
- 113
-
2How are you calling this? – Demodave Jun 19 '15 at 20:35
-
1@Demodave: SomeObject.jsonOut() – Leszek P Aug 16 '16 at 13:36