Пример #1
0
    def decode(self, s):
        items = []

        if s is None or len(s) == 0:
            return items

        data = json.JSONDecoder.decode(self, s)

        for obj in data:
            cls = obj["class"]

            if cls == "Project":
                o = Project(obj["name"])
                o.default = obj["default"]
            elif cls == "Category":
                o = Category(obj["name"])
                o.project_id = obj["project_id"]
            elif cls == "Task":
                o = Task(obj["name"])
                o.default = obj["enabled"]
                o.category_id = obj["category_id"]
                o.rating = obj["rating"]
                o.completed = obj["completed"]
                o.duration = obj["duration"]
            o.id = obj["id"]
            items.append(o)
        return items