Assume I have the following lists
list1 = [{"created_at": "2012-01-31T10:00:04Z"},{"created_at": "2013-01-31T10:00:04Z"}]
list2 = [{"created_at": "2014-01-31T10:00:04Z"}]
I can write the first list to a JSON file using json.dump(list1,file,indent=2) and the result is
[
{
"created_at": "2012-01-31T10:00:04Z"
},
{
"created_at": "2013-01-31T10:00:04Z"
}
]
My question is, how do I append the contents of the second list? if I simple do json.dump(list2,file,indent=2), it results in an invalid JSON file as below.
[
{
"created_at": "2012-01-31T10:00:04Z"
},
{
"created_at": "2013-01-31T10:00:04Z"
}
][
{
"created_at": "2014-01-31T10:00:04Z"
}
]
Edit: The lists are created dynamically by parsing about 8000 files. The above lists are just example. I could potentially be writing 8000 lists to the JSON file, so simple appending will not work.
"a"), I doubt you can.