Converting JSON to .NET classes can be done using System.Runtime.Serialization and System.Runtime.Serialization.JSON . I suspect that you are more interested in setting up function calls from client to server. I think it's worth trying this tutorial .
In this tutorial, you need to add a .asmx file for webservice. In the asmx file, you can create functions called by the script client. ASP.NET pages can also reference a client script generated to call .asmx functions.
If you really want to serialize JSON, you can also use the following:
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
public class JsonSerializer
{
static public string JsonSerialize(object objectToSerialize, params Type[] types)
{
DataContractJsonSerializer serializer = new DataContractJsonSerializer(
types[0], types.Skip(1));
MemoryStream ms = new MemoryStream();
serializer.WriteObject(ms, objectToSerialize);
ms.Seek(0, SeekOrigin.Begin);
StreamReader sr = new StreamReader(ms);
return sr.ReadToEnd();
}
}
source
share