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?

1 Answer 1

82

Try this:

public string jsonOut()
{
    // Returns JSON string.
    return JsonConvert.SerializeObject(this);       
}
Sign up to request clarification or add additional context in comments.

2 Comments

How are you calling this?
@Demodave: SomeObject.jsonOut()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.