0

I receive a JSON object from a web service. I can successfully deserialize this object with Json.net. But when I want to send this object with my WCF service using data contract serializer, I get a

System.Runtime.Serialization.InvalidDataContractException Type 'Newtonsoft.Json.Linq.JToken' is a recursive collection data contract which is not supported. Consider modifying the definition of collection 'Newtonsoft.Json.Linq.JToken' to remove references to itself.

If I create a clone of this object then I can send it out. But why not with the deserialized Json.net object?

Best Regards

Ehsan Sajjad
  • 61,834
  • 16
  • 105
  • 160

1 Answers1

0

WCF doesn't use JavascriptSerializer. It uses DataContractJsonSerializer. Replace it with Json.NET by writing a custom message formatter.

Check out this link

Mallikh
  • 16
  • 5