Unable to assign constants (or any non json object properties) to class
Closed this issue · 2 comments
benrudolph commented
Not sure if this is bug or feature, but I was using this the other day and had something like this:
class MyClass(JsonObject)
name = StringProperty()
address = StringProperty()
....
PREFIX = "MyRandomPrefix"
and this would cause jsonobject to choke
dannyroberts commented
Hmm, I'd expect that to add 'PREFIX': 'MyRadomPrefix' to the json output. But I think for what you want you can use _PREFIX
because properties with an underscore are ignored from json output
benrudolph commented
just tried it again and it does seem to work. i think things were getting funky cause i was trying to call PREFIX in the init function. good to know about the _