2013-11-27 77 views
1

我需要解析一個活動提要,但每個數組都沒有括號,所以我有點困惑。這也是有效的JSON,因爲我使用在線服務進行檢查。我想指定上下文,然後獲取數據。有誰知道我該如何做到這一點,以及可能的背景是什麼?解析數組周圍沒有方括號的JSON

在這種情況下,我想要「名稱」,「競爭對手」和其他一些領域。任何幫助感激地收到。

{ 
"604377": { 
    "competitors": { 
     "3521278": { 
      "Name": "Brazil", 
      "Jockey": null, 
      "Weight": null, 
      "Saddle": 0, 
      "Barrier": null, 
      "QLDWin": 0, 
      "VICWin": 0, 
      "NSWWin": 0, 
      "QLDPlace": 0, 
      "VICPlace": 0, 
      "NSWPlace": 0, 
      "DetailedPricing": { 
       "winTotePlus": false, 
       "placeTotePlus": false, 
       "topFluc": false, 
       "bestOfBest": false, 
       "bestOrSP": false, 
       "fixedOdds": false, 
       "fixedWin": true, 
       "doubleFixedWin": 0, 
       "bestOfEverythingWin": 0, 
       "bestAnytimeWin": 0, 
       "fixedPlace": true, 
       "startPriceGuarantee": 0, 
       "fixedEachWay": true, 
       "placePrices": [ 
        0 
       ], 
       "startPrice": false, 
       "internationalStartPrice": false, 
       "midToteWin": false, 
       "midTotePlace": true, 
       "topToteWin": true, 
       "topTotePlace": false, 
       "top2ToteWin": false, 
       "top2TotePlace": false, 
       "vicToteWinPlus1": false, 
       "vicTotePlacePlus1": false, 
       "vicToteWinPlus2": false, 
       "vicTotePlacePlus2": false, 
       "vicToteWinPlus5": false, 
       "vicTotePlacePlus5": false, 
       "vicToteWinPlus10": false, 
       "vicTotePlacePlus10": false, 
       "exoticBet": true, 
       "exoticMidTote": false, 
       "exoticBest2Tote": false, 
       "exoticBest3Tote": false, 
       "pickYourOdds": false, 
       "firstfour": true, 
       "midToteWinPrice": 0, 
       "midTotePlacePrice": 0, 
       "topToteWinPrice": 0, 
       "top2ToteWinPrice": 0, 
       "top2ToteOrSPWinPrice": 0, 
       "vicToteWinPlus1Price": 0, 
       "vicToteWinPlus2Price": 0, 
       "vicToteWinPlus5Price": 0, 
       "vicToteWinPlus10Price": 0, 
       "topTotePlacePrice": 0, 
       "top2TotePlacePrice": 0, 
       "vicTotePlacePlus1Price": 0, 
       "vicTotePlacePlus2Price": 0, 
       "vicTotePlacePlus5Price": 0, 
       "vicTotePlacePlus10Price": 0, 
       "topFlucPrice": 0, 
       "lastFlucPrice": 0, 
       "bestOfBestPrice": 0, 
       "bestOrSPPrice": 0, 
       "bestOrSPPlacePrice": 0.75, 
       "winDeduction": 0, 
       "placeDeduction": 0, 
       "competitor": 11863763, 
       "sport": "Soccer", 
       "saddle": 0, 
       "description": "Brazil 2014 - World Cup Winner ", 
       "team": "Jordan", 
       "win": 0, 
       "place": 0, 
       "numOutcomes": 24, 
       "numPlacings": 1, 
       "numWinners": 1 
      }, 
      "Scratched": "no", 
      "RisaSilkID": null 
     }, 
     "3521279": { 
      "Name": "Argentina", 
      "Jockey": null, 
      "Weight": null, 
      "Saddle": 0, 
      "Barrier": null, 
      "QLDWin": 0, 
      "VICWin": 0, 
      "NSWWin": 0, 
      "QLDPlace": 0, 
      "VICPlace": 0, 
      "NSWPlace": 0, 
      "DetailedPricing": { 
       "winTotePlus": false, 
       "placeTotePlus": false, 
       "topFluc": false, 
       "bestOfBest": false, 
       "bestOrSP": false, 
       "fixedOdds": false, 
       "fixedWin": true, 
       "doubleFixedWin": 0, 
       "bestOfEverythingWin": 0, 
       "bestAnytimeWin": 0, 
       "fixedPlace": true, 
       "startPriceGuarantee": 0, 
       "fixedEachWay": true, 
       "placePrices": [ 
        0 
       ], 
       "startPrice": false, 
       "internationalStartPrice": false, 
       "midToteWin": false, 
       "midTotePlace": true, 
       "topToteWin": true, 
       "topTotePlace": false, 
       "top2ToteWin": false, 
       "top2TotePlace": false, 
       "vicToteWinPlus1": false, 
       "vicTotePlacePlus1": false, 
       "vicToteWinPlus2": false, 
       "vicTotePlacePlus2": false, 
       "vicToteWinPlus5": false, 
       "vicTotePlacePlus5": false, 
       "vicToteWinPlus10": false, 
       "vicTotePlacePlus10": false, 
       "exoticBet": true, 
       "exoticMidTote": false, 
       "exoticBest2Tote": false, 
       "exoticBest3Tote": false, 
       "pickYourOdds": false, 
       "firstfour": true, 
       "midToteWinPrice": 0, 
       "midTotePlacePrice": 0, 
       "topToteWinPrice": 0, 
       "top2ToteWinPrice": 0, 
       "top2ToteOrSPWinPrice": 0, 
       "vicToteWinPlus1Price": 0, 
       "vicToteWinPlus2Price": 0, 
       "vicToteWinPlus5Price": 0, 
       "vicToteWinPlus10Price": 0, 
       "topTotePlacePrice": 0, 
       "top2TotePlacePrice": 0, 
       "vicTotePlacePlus1Price": 0, 
       "vicTotePlacePlus2Price": 0, 
       "vicTotePlacePlus5Price": 0, 
       "vicTotePlacePlus10Price": 0, 
       "topFlucPrice": 0, 
       "lastFlucPrice": 0, 
       "bestOfBestPrice": 0, 
       "bestOrSPPrice": 0, 
       "bestOrSPPlacePrice": 0.75, 
       "winDeduction": 0, 
       "placeDeduction": 0, 
       "competitor": 11863763, 
       "sport": "Soccer", 
       "saddle": 0, 
       "description": "Brazil 2014 - World Cup Winner ", 
       "team": "Jordan", 
       "win": 0, 
       "place": 0, 
       "numOutcomes": 24, 
       "numPlacings": 1, 
       "numWinners": 1 
      }, 
      "Scratched": "no", 
      "RisaSilkID": null 
     }, 
     "3521280": { 
      "Name": "Spain", 
+0

你是對的,沒有陣列!那些是字典!你想用哪種語言來解析它?在Objective-C中,它就像'NSDictionary * jsonDictionary = [NSJSONSerialisation JSONObjectWithData:yourDownloadedData options:kNilOptions error:NULL];'一樣簡單。傳遞NULL不是很好的做法,所以你可能想把它改爲'NSError **';) – HAS

回答

1

您還沒有指定的語言/平臺,要做到這一點。我會假設.NET ...

http://www.nuget.org/packages/newtonsoft.json/

 WebRequest request = WebRequest.Create(query); 
     using (var response = request.GetResponse()) 
     { 
      using (var responseStream = response.GetResponseStream()) 
      { 
       using (var streamReader = new StreamReader(responseStream)) 
       { 
        try 
        { 
         JsonReader reader = new JsonTextReader(streamReader); 
         dynamic result = JObject.Load(reader); 

還有很多其他的JSON解析器在那裏爲.NET和其他平臺

+0

我使用的模塊需要我添加這種類型的語法:上下文:$ .store.book。* 標題:標題 作者:作者我是一個非常新手!我的示例文檔可以完美導入,但我需要的文檔不會,它必須與它的形成方式有關。 –

+0

您上面的帖子中的json顯示不完整。您需要發佈完整的json字符串以便人們瞭解問題。 – Mick