2

i dont know how to send JSON data to server side function and also i dont know how to de-serialize the JSON data to a particular class.

suppose i need to send customer related info from client side to server side through json and jquery and i want that customer info will be deserialize to my customer class in the server side. please help me code & concept.

casperOne
  • 73,706
  • 19
  • 184
  • 253
Mou
  • 15,673
  • 43
  • 156
  • 275
  • 1
    You should try Googling first. http://www.webdevbros.net/2007/04/26/generate-json-from-asp-datatypes/ and http://code.google.com/p/aspjson/ are both JSON decoders – Justin Johnson May 04 '11 at 09:12
  • i search and i got few links but their approach was different. they are sending complex data to client size after converting to json format. so i need a guide which enable me to send complex data from client side to server side and decode there to my class. – Mou May 04 '11 at 10:18
  • You might look in this similar thread: http://stackoverflow.com/questions/1019223/any-good-libraries-for-parsing-json-in-classic-asp – Bradley Staples Jul 20 '11 at 19:36

1 Answers1

0

ASP.NET will handle JSON deserializing a page method's parameters automatically.

For example, if you have this Person class:

public class Person {
  public string FirstName { get; set; }
  public string LastName { get; set; }
  public string Address { get; set; }
  public string City { get; set; }
  public string State { get; set; }
  public string Zip { get; set; }
}

And a page method that accepts a parameter of that type:

[WebMethod]
public static void DoSomethingWithPerson(Person ThePerson)

If you pass JSON like this into the method:

{"ThePerson":{"FirstName":"Dave","LastName":"Ward"}}

Then, the ASP.NET will automatically convert the JSON to an instance of the Person class and send that into the page method as ThePerson.

Dave Ward
  • 59,815
  • 13
  • 117
  • 134