json format help

According to the specs:

"seasonnumber": "1",

should be:

"seasonNumber": 1,

Using camelCase, and an integer attribute, not string.

^^^
The same applies to episodeNumber.

And you’re missing 4 required properties from your episode object (easier to spot now that you have code tags and indentation)

It’s all in the specs https://github.com/rokudev/feed-specifications/blob/master/direct-publisher-feed-specification.md

The example in the spec:


{
  "id": "1509428502952",
  "title": "The Amazing First Episode Title",
  "content": {
    ...
  },
  "thumbnail": "https://example.org/cdn/thumbnails/1509428502952/1",
  "episodeNumber": 1,
  "shortDescription": "Marvelous episode description"
}

Unfortunately, even if you do read the specs, there are some obvious errors in them, which can make it understandably difficult to make progress.

For example, the spec states that seasonNumber is an Integer:

seasonNumber integer Required Sequential season number. E.g.: 3 or 2015.

Yet their example below that statement uses a string:


{
  "seasonNumber": "1",
  "episodes": [
    ...
  ]
}

And Roku’s example for the “episode” object is also missing a required attribute: releaseDate.

I can understand why you’re pulling your hair out. From what I can tell though, I’d go with what the spec says for the object descriptions, bearing in mind that Roku don’t test or verify their documentation examples.

I tried it as an integer, no quotes… when I submitted the feed it said that it was missing or less then zero so I put quotes around the numbers.. still waiting for the feed to report error details…

The docs did include a “dateadded” designation and I did include that between the episode brackets for each video. Yet it says it is missing…

 "dateAdded": "2016-03-03T12:35:13+00:00",

right under the “id” designation for each episode, that is why I am thinking that the order is important. whereas the order is not important if it was a “video” as opposed to a “series”.. (I’m getting better at keeping it all lowercase, lol)..

it actually says “invalid date format” I checked it and it is the same format I used for the video format that is working on my other channels. I’m going to pull an all nighter, I am determined to get this working or at the very least make some forward progress. As I have suspected, the errors I am making are minor errors common to me needing a second set of eyes and brain to catch. What makes it difficult is the amount of time that has to pass before getting results. In the back of my mind I keep saying there has got to be an easier, better, more efficient way. Then I only hope the work I am doing now will help others in the future…

Which four am I missing?

"episodes": [{
                    "id": "2085",
                    "title": "S1E12 The Hanging Posse",
                    "content": {
                        "dateAdded": "2016-03-03T12:35:13+00:00",
                        "videos": [{
                            "url": "http://www.tvbydemand.com/...../finished.ism/manifest",
                            "quality": "SD",
                            "videoType": "SMOOTH",
                            "duration": "3623",
                            "thumbnail": "http://www.tvbydemand.com/images/bonanza.JPG",
                            "episodenumber": "12",
                            "shortDescription": "S1E12 The Hanging Posse"
                        }]
                    }

The six you listed in the example are there… I’m missing what your saying…

You only have id, title, and content. You also need thumbnail, episodeNumber, releaseDate, and shortDescription. https://github.com/rokudev/feed-specifications/blob/master/direct-publisher-feed-specification.md#episode

And they need to be properties of the episode object, not the content object.

Those need to be repeated outside of the content brackets? because they are in there?
except “releasedate”, I am missing that one.
But I also figured out the date error. Everywhere else you have to use that funky date format “2015-11-11T22:21:37+00:00” but for the “dateadded” it is supposed to be mm/dd/yyyy

I think I see what you mean, in the series those things are missing…
Gonna work on these things now…

[upload|ioiVPz3cJT3Arp+FH2paTQ==]

All those error messages look legitimate based on the JSON you’ve posted. Look at each error message and make sure the properties it is referring to appear in the correct object, and have the correct type. If an object has another object as a property you can’t put the including object’s properties in the included object. The included object has its own properties, which also must be defined if required, and of the correct type. And the episode’s releaseDate should be defined exactly as the spec says to define it; just because another date or date/time field includes a time component, doesn’t mean they all do. You just have to go through each property of each object IN THE SPEC, comparing with your JSON, and make sure it matches what the spec says it should be.

I went through the docs and comiled this as an example, I did this first and posted it in the beginning of this threa, I have regone through it several times to check it. It looks proper to the best of my ability, maybe I am missing something??

{
    "providerName": "Acme Productions",
    "lastUpdated": "2015-11-11T22:21:37+00:00",
    "language": "en",
    "Series": [{
        "id": "1509428502952",
        "title": "The Amazing Series with Seasons!",
        "seasons": [{
            

        "seasonNumber": "1",
            "episodes": [{
                "id": "1509428502952",
                "title": "The Amazing First Episode Title",
                "content": {
                    "dateAdded": "2015-11-11T22:21:37+00:00",
                    "videos": [{
                        "url": "https://example.org/cdn/videos/1509428502952",
                        "quality": "UHD",
                        "videoType": "HLS"
                    }],
                    "duration": 1290
                },

                "thumbnail": "https://example.org/cdn/thumbnails/1509428502952/1",
                "episodeNumber": 1,
                "shortDescription": "Marvelous episode description"
            }]
        }],
        "genres": [
            "educational",
            "science fiction",
            "thriller"
        ],
        "thumbnail": "https://example.org/cdn/thumbnails/1509428502952/1",
        "shortDescription": "Wondrous series seasons."
    }]
}

The missing quotes treating duration and episodenumber as integer as shown in the examples in the docs and enclosed in quotes as shown in the instructions. This can be experimented with.
I saw no where in the docs (and maybe I am just missing it) for a key phrase of episode duration, there is a duration variable under episode though. This example also is in the exact order as posted in the docs. Basically if someone wants to doublecheck this example code to the docs or a working version I’d appreciate it.

Watch those cases:

Series

In your episode object, and in your series object:

"releaseDate": "2015-11-11",

And I’m pretty sure that seasonNumber should be an integer, not a string, but you can experiment with that.

duration is a property of the content object; you already have that.

There are other errors too. For example, series is an object, not an array. It’s important to distinguish where the spec requires an array of objects [ {}, {}, {} ], versus just an object by itself: {}.

Try this. I haven’t tested it, but I’m sure it’ll get you a lot closer:


{
  "providerName": "Acme Productions",
  "lastUpdated": "2015-11-11T22:21:37+00:00",
  "language": "en",
  "series": {
    "id": "1509428502952",
    "title": "The Amazing Series with Seasons!",
    "seasons": [
      {
        "seasonNumber": 1,
        "episodes": [
          {
            "id": "1509428502952",
            "title": "The Amazing First Episode Title",
            "content": {
              "dateAdded": "2015-11-11T22:21:37+00:00",
              "videos": [
                {
                  "url": "https://example.org/cdn/videos/1509428502952",
                  "quality": "UHD",
                  "videoType": "HLS"
                }
              ],
              "duration": 1290
            },
            "thumbnail": "https://example.org/cdn/thumbnails/1509428502952/1",
            "episodeNumber": 1,
            "releaseDate": "2015-11-11",
            "shortDescription": "Marvelous episode description"
          }
        ]
      }
    ],
    "genres": [
      "educational",
      "science fiction",
      "thriller"
    ],
    "thumbnail": "https://example.org/cdn/thumbnails/1509428502952/1",
    "releaseDate": "2015-11-11",
    "shortDescription": "Wondrous series seasons."
  }
}

That works well on lint.. Now I’m trying to figureo ut which brackets to put the next episode in between… Bug eyed right now, gonna take a break and then go learn me what these brackets all mean in json format. (This is why I never did java, too many unnecessary brackets!! I still love line numbers in my programs, lol)

“episodes” is an array […] of episode objects {…}

To get more episodes, put as many sets of episode objects as you need, separated by commas:

“episodes”: [
{
… first episode stuff …
},
{
… second episode stuff …
},
{
… third episode stuff …
}
]

For example:


{
  "providerName": "Acme Productions",
  "lastUpdated": "2015-11-11T22:21:37+00:00",
  "language": "en",
  "series": {
    "id": "1509428502952",
    "title": "The Amazing Series with Seasons!",
    "seasons": [
      {
        "seasonNumber": 1,
        "episodes": [

          {
            "id": "1509428502952",
            "title": "The Amazing First Episode Title",
            "content": {
              "dateAdded": "2015-11-11T22:21:37+00:00",
              "videos": [
                {
                  "url": "https://example.org/cdn/videos/1509428502952",
                  "quality": "UHD",
                  "videoType": "HLS"
                }
              ],
              "duration": 1290
            },
            "thumbnail": "https://example.org/cdn/thumbnails/1509428502952/1",
            "episodeNumber": 1,
            "releaseDate": "2015-11-11",
            "shortDescription": "Episode 1"
          },

          {
            "id": "1509428502953",
            "title": "The Amazing Second Episode Title",
            "content": {
              "dateAdded": "2015-11-11T22:21:37+00:00",
              "videos": [
                {
                  "url": "https://example.org/cdn/videos/1509428502952",
                  "quality": "UHD",
                  "videoType": "HLS"
                }
              ],
              "duration": 1290
            },
            "thumbnail": "https://example.org/cdn/thumbnails/1509428502952/1",
            "episodeNumber": 2,
            "releaseDate": "2015-11-11",
            "shortDescription": "Episode 2"
          },

          {
            "id": "1509428502954",
            "title": "The Amazing Third Episode Title",
            "content": {
              "dateAdded": "2015-11-11T22:21:37+00:00",
              "videos": [
                {
                  "url": "https://example.org/cdn/videos/1509428502952",
                  "quality": "UHD",
                  "videoType": "HLS"
                }
              ],
              "duration": 1290
            },
            "thumbnail": "https://example.org/cdn/thumbnails/1509428502952/1",
            "episodeNumber": 3,
            "releaseDate": "2015-11-11",
            "shortDescription": "Episode 3"
          }

        ]
      }
    ],
    "genres": [
      "educational",
      "science fiction",
      "thriller"
    ],
    "thumbnail": "https://example.org/cdn/thumbnails/1509428502952/1",
    "releaseDate": "2015-11-11",
    "shortDescription": "Wondrous series seasons."
  }
}

So, it passes jsonlint…
But when I add it to the channel I get

"The feed URL(s) could not be validated.

  • There was a transport-level error - (Unknown ERROR)."

  • If I point it (purposesly) to a missing json file it gives server error 400

  • If I point it to the old file it gives the original error.

  • So now I’m lost on what to do next.

  • If I browse to it from the browser it works properly…

I’ve been reading up on json.. and wow..
Found out json is a javascript based syntax for sending text from a browser to a server, but is used to tasport text from server to server as well, even though that was not it’s original intent.
So, I was correct when in my head I was like “all these brackets is just like javascript”. It is and the ridiculous use of brackets in java is the main reason I stayed away from it over the last 15 years. There simply is no reason for it. they could have all been replaced by the use of clearly defined unique “keywords”. Such as runtime, could be videoruntime, episoderuntime, instead of defining a parent variable Video[runtime] and so forth…

After reading an explaination of how json works on stackoverflow, I more understand or can visualize how json works.

for instance, {videos [ duration : 360]} creates an ARRAY named video which ccontains a dimension named duration which contains the value of 360… My explaination maynot make sense to modern programers, as they were brought up thinking this way, as an old timer I am used to video(1,1) = 360 which would have translated into the first video (video(1)) first value (,1) = 360 and then the other end would have been programed to know that the first variable is the duration.. now it makes some sense to me and I do not feel like I am just copying/modyfing code to make it work.

So while this is all great stuff, and now I have a better understanding of the structure of javascript (which will open new doors and made this whole project worthwhile to me alone) I still have to say, that it is false to say that DP does require the publisher to know how to code. In the very least, json is a set of codes to transfer plain text from thier server to roku’s servers. You need to know how to code in json.

Now I am NOT saying it is not worthwhile, it most definitely is, and I will not stop till I get this thing to work, simply put this is still easier then developing with the SDK. And it still presents the “set it and forget it” promise that is most important to any developer. Hell I still have some windows 3.1 servers running at the DOT in PA. lol.. (government is so far behind).

Anyway, Belltown, your help has been invaluable, and I appreciate it. When this is all done, We should co-author a tutorial for others to follow and maybe help get some of these great video producers from the private sector get exposure on-line in the streaming format. I hate the fact that the medium is quickly being taking away from the hobbists and being stolen by the big guys like comcast and the like.

If you PM me the url link, I’ll take a look at it.

Regarding the transport error:
I put the url directly in firefox and it “transports” properly showing up as plain text from start to finish.
I am wondering if the actual error is not being caused by a limitation of memory allocation on the server running DP?
This is my largest series of video with 422 episodes.
I will post this error to Roku support directly and see what they say. although so far all they do is quote paths to the docs, which I have gone through already and did not see this limitation defined in it (if that is the problem). They have stated to me that “this format theoretically can support an unlimited number of videos”. But I never bank on theories or hypotenuses, I like tried and true facts, lol.

JSON is nothing more than a notation to describe some structured data.

Just about every high-level programming language since time began, or at least since the FORTRAN days of the 50’s, has some way of defining a data structure. Depending on the language, it may be called a struct, structure, dictionary, hash, associative array, etc., often using a collection of key/value pairs to describe the data. JSON provides a unified way of representing that data in a machine-independent, language-independent way. A JSON “object” is nothing more than a dictionary/struct, etc., a collection of key/value pairs, where the key is a string, and the value can be another object, or an array of values or a simple value (e.g. number, string).

Fundamentally, JSON is no different from XML. They both describe a data structure in a unified way, just using a different syntax. XML is more complicated than JSON. The official XML spec, https://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf, is only 14 pages long. Many programming language specs run into the hundreds of pages in length.

JSON is much less verbose and complex than XML, yet for many applications has similar capabilities. It’s become increasingly used over the past few years in computing. Many, many APIs are now specified in JSON.

Because most high-level languages support some form of struct/dictionary, etc., and because JSON is becoming so common, many languages provide some means to format a data structure into a JSON string, either natively or via third-party extensions. This relieves the developer of the need to construct a JSON string manually, so they don’t need to be concerned about the placement of brackets, braces, and commas, etc.

Even outdated technology such as Classic ASP, using an outdated scripting language such as VBScript, provides a Dictionary type (key/value pairs), whose values can be other Dictionaries, or Arrays, or simple values (numbers/strings). Once you read your data from your database, you can construct such a Dictionary, then use a third-party function, such as http://www.webdevbros.net/2007/04/26/generate-json-from-asp-datatypes/ to convert this Dictionary into a JSON string without worrying about lining up brackets and braces, and getting all the commas in the right place.