2013-11-27 42 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