20131021 headends

SD Staff
Posts: 925
Joined: Tue Aug 14, 2007 3:15 pm

JSON data standardization

Post by rkulagow »

OK, so I played around some more, and did additional reading.

The reason that the headends response isn't showing up as an array is because we're using the name of the lineup in an associative array. Apparently, unless the keys are numeric and sequential, when the JSON is encoded it has to be turned into objects. That's why there aren't square brackets.

http://stackoverflow.com/questions/1172 ... son-encode

So, if your parser can more easily digest arrays rather than groups of objects, I'll remove the lineup name as the index and that will turn it into a square bracket array.

That will also mean that the lineup will look like this:

Code: Select all

            "stationID": "53070",
            "channel": "9998"
    "stations": [
            "stationID": "32046",
            "name": "Video On Demand",
            "callsign": "VODDM",
            "broadcastLanguage": "en",
            "descriptionLanguage": "en",
            "broadcaster": {
                "city": "Woodbury",
                "state": "NY",
                "postalcode": "11797",
                "country": "United States"
            "stationID": "58457",
            "name": "Shop IDEA for the products you want and ",
            "callsign": "IDEA",
            "broadcastLanguage": "en",
            "descriptionLanguage": "en",
            "broadcaster": {
                "city": "Unknown",
                "postalcode": "00000",
                "country": "Unknown"
My original thinking was that using the stationID as the index to the array would make it easier to go directly to a particular stationID rather than looping through all of the elements, but I'm not sure that that actually saves anything since you would need to walk the array in order to get the rest of the information. And since the largest lineups aren't more than a few hundred to low thousand's channels you're only saving microseconds in any case.


Post Reply