Extend the json seriaization

Objects that are not json-serializable are asked to use a 'for_json' method that returns something json-serializable.