We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
with_dump
json
dumps
Hey
Does with_dump only support json method but not support dumps method?
@dataclass class Person(JsonSerializable .with_dump(key_transformer=KEY_TRANSFORMER_CAMELCASE) .with_load(key_transformer=KEY_TRANSFORMER_SNAKECASE)): first_name: str last_name: str arno = Person('Arno','Y') print(arno.dumps()) print(arno.json)
Result:
{"first_name": "Arno", "last_name": "Y"} {'firstName': 'Arno', 'lastName': 'Y'}
The text was updated successfully, but these errors were encountered:
Hi @nightan42643,
The .dumps() works, it returns a string. It's just not clear when you only use print, but if you call type, you'll see:
.dumps()
print
type
@dataclass class Person(JsonSerializable .with_dump(key_transformer=KEY_TRANSFORMER_CAMELCASE) .with_load(key_transformer=KEY_TRANSFORMER_SNAKECASE)): first_name: str last_name: str arno = Person('Arno','Y') print(type(arno.dumps())) print(type(arno.json))
<class 'str'> <class 'dict'>
😉
Sorry, something went wrong.
Hi @nightan42643, The .dumps() works, it returns a string. It's just not clear when you only use print, but if you call type, you'll see: @dataclass class Person(JsonSerializable .with_dump(key_transformer=KEY_TRANSFORMER_CAMELCASE) .with_load(key_transformer=KEY_TRANSFORMER_SNAKECASE)): first_name: str last_name: str arno = Person('Arno','Y') print(type(arno.dumps())) print(type(arno.json)) Result: <class 'str'> <class 'dict'> 😉
But in this case, the dumps() didn't transfer to the CAMELCASE, right?
dumps()
No branches or pull requests
Hey
Does
with_dump
only supportjson
method but not supportdumps
method?Result:
The text was updated successfully, but these errors were encountered: