Better handling of input json

Sometimes we get it as an object. Sometimes we get it as a string.
Joy.