Bill,
These are the exact steps I follow:
python manage.py dumpdata --indent=4 > fixtures/data.json
python manage.py loaddata fixtures/data.json
That is when I get:
DeserializationError: No JSON object could be decoded
I checked the json code using
http://jsonlint.com/ and it was reported as being valid. (The json code is reproduced at the end of this post for your info)
I openned the file using Notepad++, copied it all into regular Notepad.exe and then saved it as a new json file. When I do the loaddata command with that new file it works just fine.
When I copy paste the code from Notepad.exe back into a new file on Notepad++ and save that, the resultant file works just fine as well.
This link:
http://stackoverflow.com/questions/8732799/django-fixtures-jsondecodeerror suggested that the unicode text file needed to be converted to ascii. It was also pointed out that the file in a hexeditor should start with 5B and not any other byte. Sure enough, in the hexeditor, the file straight from the dump began with FF FE, but the notepad saved json file began with 5B. Could it be my setup that is at fault producing the wrong json file dump?
[
{
"pk": 1,
"model": "books.publisher",
"fields": {
"state_province": "MA",
"city": "Cambdridge",
"name": "O'Reilly Media",
"country": "USA",
"address": "73 Prince Street"
}
},
{
"pk": 2,
"model": "books.publisher",
"fields": {
"state_province": "CA",
"city": "Bakersfield",
"name": "Randomn House",
"country": "USA",
"address": "234 Hollywood Boulevard"
}
},
{
"pk": 3,
"model": "books.publisher",
"fields": {
"state_province": "NY",
"city": "New York",
"name": "Pearson Vue",
"country": "USA",
"address": "1 Wall Street"
}
},
{
"pk": 1,
"model": "books.author",
"fields": {
"first_name": "Eric",
"last_name": "Meyer",
"email": ""
}
},
{
"pk": 2,
"model": "books.author",
"fields": {
"first_name": "Seth",
"last_name": "Meyer",
"email": ""
}
},
{
"pk": 3,
"model": "books.author",
"fields": {
"first_name": "Vincent",
"last_name": "Meyer",
"email": ""
}
},
{
"pk": 1,
"model": "books.book",
"fields": {
"publisher": 1,
"authors": [
1
],
"isbn": 123456789,
"publication_date": null,
"title": "CSS: The Definitive Guide"
}
},
{
"pk": 2,
"model": "books.book",
"fields": {
"publisher": 3,
"authors": [
2
],
"isbn": 987654321,
"publication_date": null,
"title": "Primer on Banking"
}
},
{
"pk": 3,
"model": "books.book",
"fields": {
"publisher": 2,
"authors": [
1,2
],
"isbn": 543216789,
"publication_date": null,
"title": "Frolicking on the Beach"
}
}
]
On Sunday, March 4, 2012 12:04:08 AM UTC+3, Vincent Bastos wrote: