Serializing objects with JSON.Net and wrapped style

Oct 3, 2011 at 6:45 PM

Hi there:

I have a simple object, person, with two attributes: id and name, both strings

When i serialize this with JSONConvert, i get a string with only the attributes included. And my wcf REST Service is configured with WebmessagebodyStyle.Wrapped, so is expecting the attributes to be enclosed in an outter json object (e.g. "Person").

How can i do this ?


Oct 11, 2011 at 7:55 PM

You can do it like this:

var toSerialize = new { Person = yourPersonObject };
And, then, you can serialize 'toSerialize' to your WCF service.