0

I have a List with multi lists of objects:

ob = Obj()
for p in l:
    list_url_commune = scrapingCities(base_url, p)
    for u in list_url_commune:
        list_name = scaping_creches(base_url, u, number_page)
        list_dep.append(list_name)

 json_string = json.dumps([ob.__dict__ for ob in list_dep])
 print json_string

list_dep is the list with all the lists with Objects

Then, I would like to convert all the Objects in only one JSON.

In my case, I have an error with json.dumps([ob.__dict__ for ob in list_dep])

(notice: it works fine if I have only one list but here it is a List of lists)

AttributeError: 'list' object has no attribute '__dict__'

Thanks for your help !

Pedro

1
  • You should try the second solution from the question you asked an hour ago. Commented Sep 25, 2014 at 8:44

1 Answer 1

2

Just like you noticed yourself, it works fine with a list of objects, but not with a list of lists of objects. You need to go deeper:

json.dumps([[ob.__dict__ for ob in lst] for lst in list_dep])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.