asp.net - Most efficient way to parse JSON in C# -


i wondering efficient way parse json in c#? , efficient mean 1 lower response time. trying parse large amount of data using couple of methods, , response time in both of these methods high. can tell me difference between following methods? there alternative let me parse lower response time?

option 1:

httpwebrequest request = webrequest.create(jsonurl) httpwebrequest; using (httpwebresponse response = request.getresponse() httpwebresponse) {     if (response.statuscode != httpstatuscode.ok)         throw new exception(string.format(         "server error (http {0}: {1}).",         response.statuscode,         response.statusdescription));     datacontractjsonserializer jsonserializer = new datacontractjsonserializer(typeof(obj));     object objresponse = jsonserializer.readobject(response.getresponsestream()); }   

option 2:

var json = new webclient().downloadstring(jsonurl); using (memorystream ms = new memorystream(encoding.unicode.getbytes(json))) {     datacontractjsonserializer jsonserializer = new datacontractjsonserializer(typeof(obj));     object objresponse = jsonserializer.readobject(ms); }   

you can find comparison in following link.

the libraries tested:

http://sagistech.blogspot.com/2010/03/parsing-twitter-json-comparing-c.html

  • json.net - popular c# json library.
  • gapi.net - gapi.net not json parsing library, contains json parsing routines.
  • procurios - yet c# json library. see blog post how use parse twiter data.
  • javascriptserializer - .net 3.5 built-in json parser.
  • datacontractjsonserializer - .net 3.5 built-in json parser.
  • ajaxpro - c# ajax library.

enter image description here


updated:

added information based on matt johnson's comment

http://theburningmonk.com/2011/11/performance-test-json-serializers-part-ii/


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

node.js - Bad Request - node js ajax post -

uitableview - Create and use custom prototype table cells in xamarin ios using storyboard -