Python Getter And Setter For Property

February 13, 2018
import json

class Subscriber(Base):
    info = '{"name":"Hello", "age": 1}'

    @property
    def info_json(self):
        return json.loads(self.info)

    @info_json.setter
    def info_json(self, value):
        self.info = json.dumps(value)

References:

This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.