Json – Newtonsoft Object → Get JSON string


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?

Best Solution

Try this:

public string jsonOut()
    // Returns JSON string.
    return JsonConvert.SerializeObject(this);