开发者

MS SQL -> ASP.NET -> JSON

开发者 https://www.devze.com 2023-02-14 17:50 出处:网络
Does a开发者_运维技巧nyone know how to convert backend data to a json response using .NET technologies? It\'d be nice to have this and use jquery to call some information on the backend.The JavaScript

Does a开发者_运维技巧nyone know how to convert backend data to a json response using .NET technologies? It'd be nice to have this and use jquery to call some information on the backend.


The JavaScriptSerializer is commonly used class for serializing objects into JSON strings:

var serializer = new JavaScriptSerializer();
var foo = new Foo
{
    Prop1 = "value 1",
    Prop2 = 123
};

// produces: {"Prop1":"value 1","Prop2":123}
string result = serializer.Serialize(foo);

Json.NET is another third party alternative.

0

精彩评论

暂无评论...
验证码 换一张
取 消