create to_json instance method