views:

34

answers:

1

Has anyone got a RESTful WCF service (in .NET4) successfully using JSON.NET to do serialization/deserialization?

What's the best approach?

+1  A: 

Can you provide a few more details about what you're trying to do with JSON.NET? I'm not exactly sure what scenarios you're trying to deal with -- but I'll give you my general experience with JSON.NET and WCF RESTful services.

I've built a number of WCF RESTful services that are called, primarily, by my client app using jQuery's AJAX functionality. Generally, I have not had to use JSON.NET as the JsonSerializer does a fine job of serializing my return values (single values or List<T> collections) perfectly fine and can navigate through the object without issue.

The times that I've had to use JSON.NET is when I'm sending a JSON object as part of my POST variables that I've serialized on the client using the JSON2.js library. JSON.NET has done a fine job of serializing and deserializing those values without issue, too.

I like JSON.NET -- haven't had any issues. Honestly, when I started out, I thought I would use it a lot, but have found that I only need it for edge cases. Generally I rely on the built-in JSON serialization and deserialization capabilities in WCF.

I hope this helps. Please let me know if you need more info or if there are specific scenarios you're trying to handle, and I'll update my answer accordingly. Thanks!

David Hoerster
Did you just call JSON.NET explicitly inside the operation Method? or did you do something under-the-hood to make it work seamlessly?
Christopher Stott
I've always called it explicitly within my operations. I've never used it earlier in the WCF pipeline. I'm sure you could if you are building your own binding, I guess. I may have to look into that sometime.
David Hoerster