20131021 headends

20131021 headends

Postby skipfire » Mon May 19, 2014 6:03 pm

Is there a technical reason that the result of headends isn't an array? It's more difficult to read through the results since it is not an array.
skipfire
 
Posts: 14
Joined: Sat May 17, 2014 3:54 pm

Re: 20131021 headends

Postby rkulagow » Mon May 19, 2014 7:00 pm

Do you mean the call to

GET https://json.schedulesdirect.org/201310 ... code=60030

The response that's in the documentation is an array, unless I'm missing something. Why do you think it's not an array?

The JSON that comes back in the response results an array when parsed through json_decode($response, TRUE) (where TRUE means, "turn it into an array instead of a class) in PHP.
rkulagow
SD Staff
 
Posts: 911
Joined: Tue Aug 14, 2007 3:15 pm

Re: 20131021 headends

Postby skipfire » Tue May 20, 2014 2:52 pm

The documentation and the result I get return it with each lineup as an attribute and the details about that lineup are the value. There's no square bracket [] around the lineups so the object is referecned as jsonObject.60030 instead of jsonObject[0]. I also see some others return multiple JSONs in the content instead of a single array of JSON objects such as schedules and programs. That requires an extra level of parsing for at least .NET where you find line-breaks and then deserialize each line rather than deserializing the entire response and iterating through the resulting jarray.

headend documented response:
{
"60030": {
"type": "Over-the-Air",
"location": "60030",
"lineups": [
{
"name": "Antenna",
"uri": "/20131021/lineups/USA-OTA-60030"
}
]
},
"4DTV": {
"type": "Satellite",
"location": "USA",
"lineups": [
{
"name": "4DTV",
"uri": "/20131021/lineups/USA-4DTV-DEFAULT"
}
]
},
skipfire
 
Posts: 14
Joined: Sat May 17, 2014 3:54 pm

Re: 20131021 headends

Postby rkulagow » Tue May 20, 2014 7:48 pm

Not sure if this is just a .NET thing, but the returned result for the headends is a perfectly valid associative array; it's parsed correctly in PHP and at JSONlint.com. The array key is "60030", etc.

I've received a bug report about the programs and schedules having a type of JSON in the HTTP header; while each individual line is JSON, the entire returned data isn't, so I need to fix that.

In my PHP grabber I get the schedule file, save it as text to a temp directory, then iterate over the file line-by-line, decoding the JSON into an array. (Where each line is a single stationID) for further processing.
rkulagow
SD Staff
 
Posts: 911
Joined: Tue Aug 14, 2007 3:15 pm

Re: 20131021 headends

Postby pla » Sun Nov 16, 2014 1:35 pm

Hi,

I agree with with skipfire. The headend list would be easier to parse if it were something like my mockup below. I am using com.google.gson.Gson to trasnform JSON to Java POJOs. I can not transform the headend output using com.google.gson.Gson.

According to http://www.json.org/
an array begins with [ (left bracket) and ends with ] (right bracket). Values are separated by ,
.

http://pastebin.ubuntu.com/9047764/

Code: Select all

   "headends":[ 
      { 
         "headend":"60030",
         "type":"Over-the-Air",
         "location":"60030",
         "lineups":[ 
            { 
               "name":"Antenna",
               "uri":"/20131021/lineups/USA-OTA-60030"
            }
         ]
      },
      { 
         "headend":"4DTV",
         "type":"Satellite",
         "location":"USA",
         "lineups":[ 
            { 
               "name":"4DTV",
               "uri":"/20131021/lineups/USA-4DTV-DEFAULT"
            }
         ]
      }
   ]
}


Thanks, PLA
pla
 
Posts: 2
Joined: Sun Nov 16, 2014 11:54 am

Re: 20131021 headends

Postby rkulagow » Sun Nov 16, 2014 3:57 pm

I won't be making any changes to 20140530, but it's high time that we break the seal on 20141116.

I've already posted that 20131021 is now deprecated, and there will be no more data updates effective 2014-11-14, so users that are on 20131021 will be out of data by the end of the month. At that point 20140530 will become primary, and changes to the API will be entertained.

Please post a ticket to https://github.com/SchedulesDirect/JSON-Service/issues so that I can tag it as a feature request.
rkulagow
SD Staff
 
Posts: 911
Joined: Tue Aug 14, 2007 3:15 pm

Re: 20131021 headends

Postby pla » Sun Nov 16, 2014 4:47 pm

pla
 
Posts: 2
Joined: Sun Nov 16, 2014 11:54 am

Re: 20131021 headends

Postby rkulagow » Mon Mar 09, 2015 8:41 pm

I've posted an update to the ticket. On API 20141201 the response for retrieving the headends in a postal code is now:

Code: Select all
{
    "headends": [
        {
            "4DTV": {
                "type": "Satellite",
                "location": "USA",
                "lineups": [
                    {
                        "name": "4DTV - Satellite",
                        "uri": "/20141201/lineups/USA-4DTV-DEFAULT"
                    }
                ]
            }
        },
        {
            "AFN": {
                "type": "Satellite",
                "location": "USA",
                "lineups": [
                    {
                        "name": "AFN Satellite - Satellite",
                        "uri": "/20141201/lineups/USA-AFN-DEFAULT"
                    }
                ]
            }
        },
        {
            "C-BAND": {
                "type": "Satellite",
                "location": "USA",
                "lineups": [
                    {
                        "name": "C-Band",
                        "uri": "/20141201/lineups/USA-C-BAND-DEFAULT"
                    }
                ]
            }
        },
        {
            "DISH602": {
                "type": "Satellite",
                "location": "Chicago",
                "lineups": [
                    {
                        "name": "DISH Chicago - Satellite",
                        "uri": "/20141201/lineups/USA-DISH602-DEFAULT"
                    }
                ]
            }
        },
        {
            "DITV": {
                "type": "Satellite",
                "location": "USA",
                "lineups": [
                    {
                        "name": "DIRECTV - Satellite",
                        "uri": "/20141201/lineups/USA-DITV-DEFAULT"
                    }
                ]
            }
        },
        {
            "DITV602": {
                "type": "Satellite",
                "location": "Chicago",
                "lineups": [
                    {
                        "name": "DIRECTV Chicago - Satellite",
                        "uri": "/20141201/lineups/USA-DITV602-DEFAULT"
                    }
                ]
            }
        },
        {
            "ECHOST": {
                "type": "Satellite",
                "location": "USA",
                "lineups": [
                    {
                        "name": "DISH Network - Satellite",
                        "uri": "/20141201/lineups/USA-ECHOST-DEFAULT"
                    }
                ]
            }
        },
        {
            "GLOBCST": {
                "type": "Satellite",
                "location": "USA",
                "lineups": [
                    {
                        "name": "Globecast World TV - Satellite",
                        "uri": "/20141201/lineups/USA-GLOBCST-DEFAULT"
                    }
                ]
            }
        },
        {
            "GLRYSTR": {
                "type": "Satellite",
                "location": "USA",
                "lineups": [
                    {
                        "name": "GLRYSTR - Satellite",
                        "uri": "/20141201/lineups/USA-GLRYSTR-DEFAULT"
                    }
                ]
            }
        },
        {
            "IL57303": {
                "type": "Cable",
                "location": "Lake Forest",
                "lineups": [
                    {
                        "name": "Comcast Waukegan/Lake Forest Area - Digital",
                        "uri": "/20141201/lineups/USA-IL57303-X"
                    }
                ]
            }
        },
        {
            "IL61078": {
                "type": "Cable",
                "location": "Grayslake",
                "lineups": [
                    {
                        "name": "Saddlebrook Farms - Cable",
                        "uri": "/20141201/lineups/USA-IL61078-DEFAULT"
                    }
                ]
            }
        },
        {
            "IL63063": {
                "type": "Cable",
                "location": "Mchenry",
                "lineups": [
                    {
                        "name": "Comcast McHenry & Fox Areas - Digital",
                        "uri": "/20141201/lineups/USA-IL63063-X"
                    }
                ]
            }
        },
        {
            "IL63463": {
                "type": "Cable",
                "location": "Carpentersville",
                "lineups": [
                    {
                        "name": "Comcast Algonquin/Elgin Areas - Digital",
                        "uri": "/20141201/lineups/USA-IL63463-X"
                    }
                ]
            }
        },
        {
            "IL67050": {
                "type": "Cable",
                "location": "Chicago",
                "lineups": [
                    {
                        "name": "AT&T U-verse TV - Digital",
                        "uri": "/20141201/lineups/USA-IL67050-X"
                    }
                ]
            }
        },
        {
            "RELAYTV": {
                "type": "Satellite",
                "location": "USA",
                "lineups": [
                    {
                        "name": "RELAYTV - Satellite",
                        "uri": "/20141201/lineups/USA-RELAYTV-DEFAULT"
                    }
                ]
            }
        },
        {
            "60030": {
                "type": "Over-the-Air",
                "location": "60030",
                "lineups": [
                    {
                        "name": "Antenna",
                        "uri": "/20141201/lineups/USA-OTA-60030"
                    }
                ]
            }
        }
    ]
}


Does that make it easier for your JSON parser to decode the JSON?
rkulagow
SD Staff
 
Posts: 911
Joined: Tue Aug 14, 2007 3:15 pm

Re: 20131021 headends

Postby rkulagow » Tue Mar 10, 2015 12:23 pm

Would something like this work better as a headend response?

Code: Select all
[
    {
        "headend": "4DTV",
        "type": "Satellite",
        "location": "USA",
        "lineups": [
            {
                "name": "4DTV - Satellite",
                "uri": "/20141201/lineups/USA-4DTV-DEFAULT"
            }
        ]
    },
    {
        "headend": "AFN",
        "type": "Satellite",
        "location": "USA",
        "lineups": [
            {
                "name": "AFN Satellite - Satellite",
                "uri": "/20141201/lineups/USA-AFN-DEFAULT"
            }
        ]
    },
    {
        "headend": "DITV602",
        "type": "Satellite",
        "location": "Chicago",
        "lineups": [
            {
                "name": "DIRECTV Chicago",
                "uri": "/20141201/lineups/USA-DITV602-DEFAULT"
            }
        ]
    }
]
rkulagow
SD Staff
 
Posts: 911
Joined: Tue Aug 14, 2007 3:15 pm

Re: 20131021 headends

Postby sub » Tue Mar 10, 2015 1:30 pm

I'd like to be able to give you a more strong direction, but the reality is I'm still easing my way into json (after using xml for this type of stuff for years), and I haven't got a lot of strong opinions on how the data should be structured.

I can understand some developers would have wanted /schedules and /programs to return the results wrapped in an array, rather than multiple lines each with it's own json response. This wasn't a big deal for me though, I just passed each line into json parser I use (NewtonSoft).

The biggest thing for me, is whatever we go with, I don't want it to change in the next version of the API. I want the API to be as static as possible. Having to commit the time to go back and revisit these structural changes is a major pain in the bum.

In my ideal world, the API wouldn't have changed at all, with the possible exception of a different parameter being available for users wanting more days of data. I'd have hoped German/French data would have been added to the existing database. I'm ok with additional properties being added for additional data now available.

In summary, none of these proposed format changes are easier/harder to process the data, but having to update the application to accommodate changes is annoying.

(Sorry, maybe not the sort of answer you were hoping for!)
sub
 
Posts: 23
Joined: Sun Aug 19, 2007 2:18 pm

Next

Return to Developer

Who is online

Users browsing this forum: No registered users and 4 guests

cron