class A(object):

    def __init__(self):
        self.b_list = []


class B(object):

    def __init__(self):
        self.x = 'X'
self.y = 'Y'
a = A()
a.b_list.append(B())
print(dumps(a.__dict__))
Python serialize objects list to JSON