10

I wrote some ASP.NET web services that use JSON encoding, a la:

[WebInvoke()]
[OperationContract]
public int SetInformation(int recordid, string data)
{
    return 42;
}

and the returned JSON is:

{"d": 42}

Why is the parameter named d? Can I control that? Say, to e?

For reference, a few similar questions I've finally been able to dig up:

Community
  • 1
  • 1
Scott Stafford
  • 43,764
  • 28
  • 129
  • 177

1 Answers1

12

This is a "security" feature that prevents the JSON from being returned from being able to be directly executed javascript inside an Eval statement. Or something very similar along these lines.

More information on this topic: http://encosia.com/a-breaking-change-between-versions-of-aspnet-ajax/ take a look at the section labeled Waiter, there’s a .d in my msg soup!

Chris Marisic
  • 32,487
  • 24
  • 164
  • 258
  • Great article that appears to be the definitive word on the subject. It doesn't say why "d" specifically was chosen, though... ;) Short for data? – Scott Stafford Jul 06 '11 at 13:33
  • I would surmise that they choose d for short for data to add the minimal amount of json overhead to the payload. It probably would have been much cleaner of them to have actually used Data or even Payload or other more descriptive word. – Chris Marisic Jul 06 '11 at 14:52