开发者

Using:JavascriptConverter in ASP.NET

I'm currently serializing objects like this:

public static string ObjToJson(List<MyObject> TheObjects){

  JavascriptSerializer TheSerializer = new JavascriptSerializer();
  TheSerializer.RegisterConverters( new JavascriptConverter [] { new ObjectToJson() });
  string JsonObj = TheSerializer.Serialize(TheObjects);
  return JsonObj; }
开发者_Python百科

And then I have this:

public class TheObjToJson : JavascriptConverter{
 public override IDictionary<string,object> Serialize (object obj, JavascriptSerializer serializer)
    {
    ...
     return jsonstring;
    }
}

Is this the fastest/best way to do JSON in ASP.NET?


I think the most popular JSON library is json.net. It's fast and easy to use.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜