Throw an error if JSON is bad.

It's easy to mess up the JSON format, so throw an error early if it is
bad.

Change-Id: I9b15968274fb9fb8a44908fe38e0d4d732dd42e5