Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

JSON Serialization and Deserialization in ASP.Net


    
JSON Serialization and Deserialization in ASP.Net
 
I was looking around for a simple example which would just do an object serialization to a JSON format, and then deserializing back to the original object. I found few examples on MSDN, but did seem to be too long to try. Here I've given a simple code which would make your understanding easy, and simpler.
 
 
What is JSON?
 
JSON is another format of expressing data, just like XML. But, JSON is very simpler than XML, and tiny than XML. So, it is becoming popular in the web world to choose the JSON notation over XML since JSON notation are usually shorter, and less data to be transmitted if at all they were to be.
 
Okay, I understood a little about JSON. Give me an example!
 
I know an example will get your understanding much better. Below is a simple example of how an object can be expressed in JSON notation. Let's take a classical example of a Person object, and expressing myself as an object.
{
   "firstName": "Rakki",
   "lastName":"Muthukumar",
   "department":"Microsoft PSS",
   "address": {
      "addressline1": "Microsoft India GTSC",
      "addressline2": "PSS - DSI",
      "city": "Bangalore",
      "state": "Karnataka",
      "country": "India",
      "pin": 560028
   }
   "technologies": ["IIS", "ASP.NET","JavaScript","AJAX"]
}
In the above example, address is another object inside my Person, and technologies is an array or strings.
 
Express this as a simple .NET class, please!
 
Here is a simple example.
public class Address
{
    public string addressline1, addressline2, city, state, country;
    public int pin;
}
 
public class Person
{
  


Ïà¹ØÎĵµ£º

ASP.NET ÑÝÁ·£ºÊ¹Óÿͻ§¶Ë½Å±¾È«Çò»¯ÈÕÆÚ


      ÔÚ±¾ÑÝÁ·ÖУ¬Äú½«Ê¹Óà ECMAScript (JavaScript) ÒÔÈ«Çò»¯¸ñʽÏÔʾÈÕ¡¢ÔºÍÆäËûÓëÈÕÆÚÏà¹ØµÄÖµ¡£ASP.NET ÖÐµÄ AJAX ¹¦ÄÜ»ùÓÚ ScriptManager ¿Ø¼þÖеÄÉèÖÃÌṩ¿Í»§¶ËÈ«Çò»¯Ö§³Ö¡£½«ÕâЩȫÇò»¯ÉèÖÃÓ¦ÓÃÓÚ Web Ó¦ÓóÌÐòºó£¬¿ÉÒÔʹÓÿͻ§¶Ë½Å±¾»ùÓÚÇøÓòÐÔÖµÉèÖà JavaScript Date »ò Number ¶ÔÏ ......

asp.netÖÐweb.configÎļþÅäÖÃ

Ò»¡¢ÈÏʶWeb.configÎļþ
  
  ¡¡¡¡Web.configÎļþÊÇÒ»¸öXMLÎı¾Îļþ£¬ËüÓÃÀ´´¢´æ ASP.NET Web Ó¦ÓóÌÐòµÄÅäÖÃÐÅÏ¢£¨Èç×î³£ÓõÄÉèÖÃASP.NET Web Ó¦ÓóÌÐòµÄÉí·ÝÑéÖ¤·½Ê½£©£¬Ëü¿ÉÒÔ³öÏÖÔÚÓ¦ÓóÌÐòµÄÿһ¸öĿ¼ÖС£µ±Äãͨ¹ýVB.NETн¨Ò»¸öWebÓ¦ÓóÌÐòºó£¬Ä¬ÈÏÇé¿öÏ»áÔÚ¸ùĿ¼×Ô¶¯´´½¨Ò»¸öĬÈϵÄ
&nb ......

asp.netÐÔÄÜÓÅ»¯µÄ¼¸¸ö·½Ãæ

c#£¨»òvb.net£©³ÌÐò¸Ä½ø
1¡¢Ê¹ÓÃÖµÀàÐ͵ÄToString·½·¨
¡¡¡¡ÔÚÁ¬½Ó×Ö·û´®Ê±£¬¾­³£Ê¹ÓÃ"+"ºÅÖ±½Ó½«Êý×ÖÌí¼Óµ½×Ö·û´®ÖС£ÕâÖÖ·½·¨ËäÈ»¼òµ¥£¬Ò²¿ÉÒԵõ½ÕýÈ·½á¹û£¬µ«ÊÇÓÉÓÚÉæ¼°µ½²»Í¬µÄÊý¾ÝÀàÐÍ£¬Êý×ÖÐèҪͨ¹ý×°Ïä²Ù×÷ת»¯ÎªÒýÓÃÀàÐͲſÉÒÔÌí¼Óµ½×Ö·û´®ÖС£µ«ÊÇ×°Ïä²Ù×÷¶ÔÐÔÄÜÓ°Ïì½Ï´ó£¬ÒòΪÔÚ½øÐÐÕâÀà´¦Àíʱ£¬½«ÔÚÍйܶÑÖÐ ......

Ò»¸öasp.netͼƬÑéÖ¤Âë³ÌÐò

Êý×Ö/×Öĸ»ìºÏºÜ¼òµ¥µÄ£¬¿´×űȽÏÊæ·þ£¬Ç°Ì¨Éú³ÉµÄaspxÎļþÎҾͲ»Ìù³öÀ´ÁË£¬Ä¬Èϵģ¬ÎÒҲδ×÷Ð޸ġ£ÏÂÃæÖ»Ìù³öºǫ́µÄcs´úÂë¡£½ö¹©²Î¿¼¡£
public partial class CheckCode : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.CreateCheckCodeImage( ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ