Skip to content

Instantly share code, notes, and snippets.

@haluzpav
Last active February 10, 2019 23:47
Show Gist options
  • Save haluzpav/b578dad460cb3670d55305dc65d9d2bf to your computer and use it in GitHub Desktop.
Save haluzpav/b578dad460cb3670d55305dc65d9d2bf to your computer and use it in GitHub Desktop.
Jsons bug - property of nested object
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