0

I've got:

class Catalog():
    Categories = []

class Category():
    Subcategories = []
    Courses = []
    def __init__(self, title):
        self.Title = title

It goes on, where subcategories and courses have child objects as well, but I'm having trouble JSON serializing this whole complex object. It barfs:

Object of type Catalog is not JSON serializable

I have also made all of these classes inherit from this, based on an article that I read, but it seems to have no effect.

class ContentBase(object):
    def __repr__(self):
        return json.dumps(self.__dict__)

How can I create an entire tree of categories, subcategories, courses, chapters, and lessons and be able to dump that all out as JSON?

Russ
  • 41
  • 5

0 Answers0