Add a from_json() function.