What does .d in JSON mean?
Are you referring to the ADO.NET Data Services?
I remember hearing a presentation about the JSON returning this and I think its just a wrapper to ensure the payload is a JSON object as opposed to an array (which is the case of returning multiple entities).
Why 'd' specifically? I think I remember them saying something like 'well it had to be something'.
Based on this tutorial: JSON Web Service And jQuery with Visual Studio 2008
The Web Method returns a Product that is serialized in JSON format. Since there is not JSON
type, the returned value is a String
with JSON format.
On the client side, the ajax call returns a JSON.
The result looks like {d: 'returned-string-with-JSON-format'}
More exactly something like: {d:'{"ID":123,"Name":"Surface Pro 2"}'}
Note that 'returned-string-with-JSON-format'
is a string not a JSON object so you cannot do result.d.ID
.
Instead you need to convert it to JSON object by using JSON.parse(result.d)
or eval(result.d)
At the end, what you really want is do this:
result = JSON.parse(result.d)
UPDATE Also consider this demo, where I use a JSON in string format and convert it to JSON object: