Sunday, March 28, 2010

response.d in .net 3.5 JSON

Migrate Json .Net 2.0 to .Net 3.5

Here need to be note...
================
response.d

While I wish this unexpected change had been more clearly announced, it’s a good one. Here’s how Dave Reed explained it to me:

{"d": 1 }



Is not a valid JavaScript statement, where as this:



[1]



Is.



So the wrapping of the "d" parameter prevents direct execution of the string as script. No Object or Array constructor worries.

[] is JavaScript’s array literal notation, allowing you to instantiate an array without explicitly calling a constructor. To expand on Dave’s explanation, simply consider this code:


=====================
make sure you change web.config to use ScriptService of v 3.5 in HttpHandlers

add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"