2011-05-19 139 views
-3

任何人都可以告訴我如何使用C#解析WCF服務中的這些數據?如何解析JSON數據

{"syncresp": { 

    "synchdr": { 

    "sessionref": "1234567890"     
    "syncref": "20110327T012000"       

    }, 

    "syncbody": { 

    "syncedrecs": [ 
     { 
     "recloc": "plog,0,123", 
     }, 
     { 
     "recloc": "plog,0,123", 
     } 
    ], 
    "serverdata": [ 

     { 
     "table": " book", 
     "action": "new", 
     "recdata": { 
      "pnum": "67890", 
      "fname": "ghgfhn" 
      "lname": "M" 
      . 
      . 
      . 
     }, 
     }, 

     { 
     "table": "pins", 
     "action": "new", 
     "recdata": { 
     "patid": 123, 
      "insprovid": 5, 
      "insnum": "X34567", 
      "effdate": "6/3/2011", 
      "expdate": "5/3/2012", 
      "status": "a", 
     }, 
     }, 
    ]  
    } 
}} 

回答

0

這是一個很簡單的問題,所以在提出這樣的問題之前請閱讀一些手冊。在谷歌 第一個搜索結果:

http://blah.winsmarts.com/2009-12-How_to_parse_JSON_from_C-.aspx

JavaScriptSerializer jSerialize = new JavaScriptSerializer(); 
BusinessObjectType businessObject = jSerialize.Deserialize<BusinessObjectType>(configuration);