Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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Öг£ÓõÄÈýÊ®ÈýÖÖ´úÂë

1. ´ò¿ªÐµĴ°¿Ú²¢´«ËͲÎÊý£º
´«ËͲÎÊý£º
response.write("£¼script£¾window.open('*.aspx?id="+this.DropDownList1.SelectIndex+"&id1="+...+"')£¼/script£¾")
½ÓÊÕ²ÎÊý£º
string a = Request.QueryString("id");
string b = Request.QueryString("id1");
2.Ϊ°´Å¥Ìí¼Ó¶Ô»°¿ò
Button1.Attributes.Add("o ......

asp.net ½«ÖÐÎÄ·­Òë³ÉÆ´Òô£¨VS2008£©

3¸öÎļþ
code ÀàÎļþ
 using System;
using System.Text;
namespace ConcreteMIS.Common.Chinese
{
    /// <summary>
    /// ºº×ÖÆ´ÒôÉùĸ¼ÆËãÀà
    /// Write by WangZhenlong at 2003/11/29
    /// </summary>
   ......

Ïê½âASP.NET»º´æµÄ¹¤×÷Ô­Àí

ÕâÀïÎÒÃǽ«½éÉÜASP.NET»º´æµÄ¹¤×÷Ô­Àí£¬°üÀ¨¼òµ¥µÄ¶¨Ò壬Êý¾Ý»º´æÒÔ¼°»º´æµÄÉèÖõȵÈÄÚÈÝ¡£Ï£Íû±¾ÎÄÄܶԴó¼Ò½ñºóµÄ¹¤×÷ÓÐËù°ïÖú¡£
ÈçºÎ±ÜÃâASP.NET»º´æÕ¼ÓÃϵͳ×ÊÔ´
ÔÙ̸ASP.NET»º´æ»úÖÆ£º¿ª·¢Ð§ÂÊÓëÓÅ»¯µÄ..
ASP.NET»º´æ»úÖÆ»ù´¡¸ÅÄî
ASP.NET»º´æÊý¾ÝÌí¼Ó·½·¨Ò»ÀÀ
ASP.NET»º´æÊý¾Ý¼¼ÇÉÈýÔò
½éÉÜ
»º´æÊÇÔÚÄÚ´æ´ ......

asp.netÖеÄÒì²½Ò³Ãæ


ÒªÏëÁ˽âasp.net 2.0µÄÒì²½Ò³µÄ´¦Àí¹ý³Ì,ÏÈÁгöÒ³ÃæµÄÉúÃüÖÜÆÚ£º
1 £ºInit ʼþ£º Ò³Ãæ³õʼ»¯ £¬³õʼ»¯ÉèÖá£
2£º LoadViewState·½·¨£º ¼ÓÔØÊÓͼ״̬£¬ Ìî³äViewStateÊôÐÔ¡£
3 £ºLoadPostData·½·¨£º ´¦Àí»Ø·¢Êý¾Ý£¬ ´¦Àí´«Èë´°ÌåÊý¾Ý¡£
4£º Load ʼþ£º ¼ÓÔØÒ³Ãæ £¬Ò³Ãæ¿Ø¼þ³õʼ»¯Íê³É²¢·´Ó³Á˿ͻ§¶ËµÄÊý¾Ý¡£
5 £ºRa ......

VC6.0µ÷ÓÃASP.NET WebServiceʾÀý

¿ª·¢Æ½Ì¨£º
WinXP SP3+IIS5.1+IE7+Visual Studio 2005+Visual Studio 6.0+ MS SOAP Toolkit 3.0
 
Ò»£®´´½¨ASP.NET WebService
Visual Studio 2005àÎļþàн¨àÍøÕ¾àASP.NET Web·þÎñÏîÄ¿WebServiceDemo¡£
ÒÔÏÂΪService.cs´úÂëÇåµ¥£º
// WebService.cs
using System;
using System ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ