The Movie Database Support

Here is a feedback regarding the API method:

From strongly typed language (in my case C#) perspective the problematic point here is that the rated property in the response message can be either

  • Boolean (=> primitive type in "naked" non-wrapped form)
  • Or a wrapped number (=> a primitive number wrapped into an object)

depending on the result (whether the user already has posted a rating for the Movie in question).

In .NET/C# when deserializing with the standard Newtonsoft.Json serializer a default, unconfigured call to the deserializer will not provide meaningful, usable results.

I can not speak for other languages, but in my experience strongly typed languages don't encourage the developer use dynamic binding of types. And as such if possible the API server should return objects where the types of properties are known before deserialization.

Please also note that this response object is also silly: all its states could be described with 1. a nullable value type, which either is null (if it has no value i.e.: user did not rate the movie) or contains the actual value (user has already rated the movie) 2. alternatively with a simple number containing the rating itself, or NumberType.MinValue if no rating available.

If other .NET devs are reading this post, the easiest, best behaving partial solution to the above problem is to call the deserializer with custom Error-handling attribute:

Minimalist mock code:

    public class Status
        public int id { get; set; }
        public bool favorite { get; set; }
        public ValueWrapper rated { get; set; }
        public bool watchlist { get; set; }
// ValueWrapper only wraps the 'rating' value. If we have to deserialize a bool, it will default to null
    public class ValueWrapper
    { public long value { get; set; } }

    var ratedStatus = JsonConvert.DeserializeObject<Status>(json, new JsonSerializerSettings() { Error = delegate (object sender, ErrorEventArgs args) { args.ErrorContext.Handled = true; }});


Error = delegate (object sender, ErrorEventArgs args) { args.ErrorContext.Handled = true; }

Attribute on the Deserializer will make sure that any exceptions thrown when reading an unexpected token (reading "rating" = false when we expect a ValueWrapper object) get silently swallowed and the rated property gets initialized to its default value null .


s focus the search bar
p open profile menu
esc close an open window
? open keyboard shortcut window

On media pages

b go back (or to parent when applicable)
e go to edit page

On TV season pages

(right arrow) go to next season
(left arrow) go to previous season

On TV episode pages

(right arrow) go to next episode
(left arrow) go to previous episode

On all image pages

a open add image window

On all edit pages

t open translation selector
ctrl+ s submit form

On discussion pages

n create new discussion
w toggle watching status
p toggle public/private
c toggle close/open
a open activity
r reply to discussion
l go to last reply
ctrl+ enter submit your message
(right arrow) next page
(left arrow) previous page