Returning a JSON Object from PageMethod with Custom Formatting

Is it possible to format how an object is returned as JSON from PageMethod? i.e. removing the first d element from the data without writing JSON from scratch.

From {"d": {"name": "bob", "email": " bob@example.com "}}

To {"name": "bob", email: " bob@example.com "}

+3
source share
2 answers

No. The Microsoft JSON serializer for some reason adds d on the server side, and the client AJAX code that deserializes the JSON string expects it to be there.

+1

"d" .NET XSS [source]. , "Content-Type" "application/json".

, (.. "d"), "Content-Type" "application/json". ( ) , .NET.

+4

Source: https://habr.com/ru/post/1702160/


All Articles