Open nightan42643 opened 2 years ago
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'>
😉
Hi @nightan42643,
The
.dumps()
works, it returns a string. It's just not clear when you only usetype
, 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?
Hey
Does
with_dump
only supportjson
method but not supportdumps
method?Result: