2012-05-21 76 views
0

解析非常困難的json字符串時遇到了很大問題。例如使用不同類型的內部數組解析Json

{ 
    "facilityDetails": [ 
     { 
      "tableName": "FACILITY", 
      "facilityDetails": [ 
       { 
        "id": 1, 
        "itemId": "s101", 
        "name": "facility", 
        "status": 1, 
        "lastEditedOn": "01/Jan/201200: 00: 00.000" 
       } 
      ] 
     }, 
     { 
      "tableName": "PLACE_SERVICE", 
      "facilityDetails": [ 
       { 
        "id": 1, 
        "itemId": "22", 
        "name": "placeservice", 
        "facility": "5", 
        "status": 1, 
        "lastEditedOn": "01/Jan/201000: 00: 00.000" 
       }, 
       { 
        "id": 2, 
        "itemId": "55", 
        "name": "placeservice", 
        "facility": "t", 
        "status": 2, 
        "lastEditedOn": "01/Jan/201000: 00: 00.000" 
       }, 
       { 
        "id": 3, 
        "itemId": "99", 
        "name": "placeservice", 
        "facility": "r", 
        "status": 33, 
        "lastEditedOn": "01/Jan/201000: 00: 00.000" 
       }, 
       { 
        "id": 4, 
        "itemId": "22", 
        "name": "placeservice", 
        "facility": "", 
        "status": 0, 
        "lastEditedOn": "01/Jan/201000: 00: 00.000" 
       } 
      ] 
     }, 
     { 
      "tableName": "AGENT", 
      "facilityDetails": [ 
       { 
        "agentId": 2, 
        "itemId": "1", 
        "name": "agent", 
        "defUnitId": 0, 
        "defRouteId": 0, 
        "color": "", 
        "synonyms": "", 
        "administrationType": 0, 
        "status": 0, 
        "lastEditedOn": "01/Jan/201200: 00: 00.000" 
       } 
      ] 
     } 
    ] 
} 

這個json字符串「facilityDetails」是一個內部數組,每次都有不同的細節。我該如何解析這種類型的json。如果有人知道請幫我

+1

哪種語言? –

+0

對不起。我正在使用c# – Hope

+0

是否可以使用字典。如果可能,我怎樣才能讀取該字典中的數據。因爲每次我得到相同的json都沒有必要。因爲有些時候json只包含1個設施細節,但在一段時間內只包含30個細節數組。請打算從數據庫中找出這些數據 – Hope

回答