Analizando JSON sin corchetes alrededor de las matrices

I need to parse a live feed but each array has no brackets around it so I am slightly confused. It is also valid JSON as I used an online service to check. I want to specify the context and then grab the data. does anyone know how I can do this and what the context might be?

In this case I want the "Name", "competitor" and a few other fields. Any help gratefully received.

{
"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",

preguntado el 27 de noviembre de 13 a las 03:11

You are right, there are no arrays! Those are dictionaries! In which language do you want to parse it? In Objective-C it is as easy as NSDictionary *jsonDictionary = [NSJSONSerialisation JSONObjectWithData:yourDownloadedData options:kNilOptions error:NULL];. Passing NULL is not good practice so you might wanna change that to an NSError ** ;) -

1 Respuestas

You haven't specified which language/platform you want to do this in. I'll assume .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);

There's lots of other JSON parsers out there for .NET and other platforms

respondido 27 nov., 13:03

I am using a module that requires me to add this type of syntax: Context: $.store.book.* Title: title Author: author I am very much a novice! My sample document imports perfectly but the one I need won't and it has to be something to do with the way it is formed. - rico stevens

The json in your post above appears incomplete. You'll need to post the complete json string in order for people to understand the issue. - Mick

> The json in your post above appears incomplete. Its not incomplete, its the point of the question. - frank schwieterman

@FrankSchwieterman a) your 7 and half years late on your comment... b) you can clearly see they've only posted half of the json string, it's cut off... but anyhow thanks for your patronization. - Mick

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.