ensure safe_mode param is a boolean

Right now to_json is treating the safe_mode parameter as a string, enforce boolean.