tags:

views:

13

answers:

2

Entire question is in the title: Are there any working, and tested, JSon serializer implementations for .NET 4?

I tried Json.NET on codeplex, but it is neither updated for .NET 4.0, nor does it handle culture differences (like comma/dot in floating point values).

Are there any that works?

+2  A: 

Aren't the ones built-in the framework working in your scenario (JavaScriptSerializer and DataContractJsonSerializer)? Those are guaranteed to be working and tested.

Darin Dimitrov
*smack forehead* So they're built in now? :P
Lasse V. Karlsen
@Lasse, those classes have always been part of the core framework.
Darin Dimitrov
A: 

This is what I use for my WCF4 REST service, and it works fine, so the DataContractJsonSerializer should work for you.

    public static string SerializeToJSON<T>(T obj)
    {
        string sRet = "";
        var serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(T));
        using (var memStream = new System.IO.MemoryStream())
        {
            serializer.WriteObject(memStream, obj);
            byte[] blob = memStream.ToArray();
            var encoding = new System.Text.UTF7Encoding();
            sRet = encoding.GetString(blob);
        }
        return sRet;
    }
James Black