Last active
February 10, 2019 23:47
-
-
Save haluzpav/b578dad460cb3670d55305dc65d9d2bf to your computer and use it in GitHub Desktop.
Jsons bug - property of nested object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dataclasses | |
import jsons | |
@dataclasses.dataclass | |
class B: | |
i: int | |
@property | |
def j(self): | |
return 'bananas' | |
@dataclasses.dataclass | |
class A: | |
b: B | |
@property | |
def c(self): | |
return 42 | |
a = A(B(7)) | |
s = jsons.dump(a, strip_properties=True) | |
print(s) | |
# >>> {'b': {'i': 7, 'j': 'bananas'}} | |
# 42 stripped as expected | |
# 'bananas' still present |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment