Thursday, May 30, 2013

Re: Importing data using loaddata from exported data using dumpdata

When you say "created from a dumpdata export", do you mean that the file has been edited since the export?

If so, you have probably introduced a syntax error in the JSON.

See if you can find a JSON validator site on the web, or an editor or tool that pretty prints the JSON to see if you can spot the problem.

It is just possible that the file as a whole is OK but one of your data items within it was JSON, but which is marginally formatted.

You could also try:

  $ python
  >>> import json
  >>> with open('file.json') as fp:
  >>>     obj = json.load(fp)

If this fails, there is definitely a syntax error in the file per seh.  If it succeeds try:

  >>> print json.dumps(obj, sort_keys=True, indent=4, separators=(',', ': '))

to see a prettier version you can examine.

Good luck,

Bill


On Thu, May 30, 2013 at 9:51 AM, Gitonga Mbaya <gitonga@gmail.com> wrote:
I have searched high and low for a solution to this problem and nothing I could find anywhere led to a solution. On a whim I decided to type out the json file into notepad and save it as a different json file. I then tried loading that and it worked. Next I just copy pasted the contents of the dumped json file into a new notepad file, and likewise I was able to load it. I suppose that's the only workaround for now, unless someone has a better solution.

On Sunday, March 4, 2012 12:04:08 AM UTC+3, Vincent Bastos wrote:
Hi,

I am having trouble importing data using loaddata from a .json file that I created from a dumpdata export. I have a production application which runs MySQL on one server and a development machine which runs SQLite. I simple executed ./manage.py dumpdata > file.json on the production machine, but when I execute ./manage.py loaddata file.json I get the error:

ValueError: No JSON object could be decoded

I would appreciate some sort of trouble shooting direction, as I could not find anything that would help me in the docs.

Cheers

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment