No JSON object could be decoded
See original GitHub issueRasa NLU version : latest version
Used backend : mitie
Plattform : Ubuntu-14.04
Issue: I have tried to train on a file generated using rasa-nlu-trainer, but i am getting below error .
Full stack trace :
Traceback (most recent call last): File "/usr/lib64/python2.7/runpy.py", line 174, in _run_module_as_main "__main__", fname, loader, pkg_name) File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code exec code in run_globals File "build/bdist.linux-x86_64/egg/rasa_nlu/train.py", line 72, in <module> File "build/bdist.linux-x86_64/egg/rasa_nlu/train.py", line 64, in do_train File "build/bdist.linux-x86_64/egg/rasa_nlu/training_data.py", line 35, in __init__ File "build/bdist.linux-x86_64/egg/rasa_nlu/training_data.py", line 78, in guess_format File "/usr/lib64/python2.7/json/__init__.py", line 339, in loads return _default_decoder.decode(s) File "/usr/lib64/python2.7/json/decoder.py", line 364, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib64/python2.7/json/decoder.py", line 382, in raw_decode raise ValueError("No JSON object could be decoded")
I have validated using json validator it is correct json file. we have attached config.json for mitie and also tried with mitie_sklearn getting same issue.
Attachments Data file : rasa.json.zip Config file : config.json.zip
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (4 by maintainers)
Well, this was entertaining, I learned of a new UNIX utility, today:
iconv
TL;DR
iconv -c -f UTF8 -t ASCII original.json > originalEncoded.json
fixes the issue.Somewhat more detailed, but very hypothetical, explanation: Looks like Chrome browser (at least, I’m assuming it’s tied to Chrome given that it was hard to reproduce) pushes for
UTF-8
encoding when downloading files. On the other hand, it looks likerasa_nlu.train
expectsASCII
encoded files. Using:iconv -c -f UTF8 -t ASCII original.json > originalEncoded.json
converts the downloaded file to ASCII-readable encoding, allowing Python2.7 to play nicely with it. Don’t forget the
-c
flag, or you’ll get aiconv: could not convert
error (at least, I did).If you’re not sure you have the right encodings installed on your machine (you should though, this stuff is default), just issue
iconv -l
, it’ll list all the encodings.Thanks for your help. The issue is with the BOM (which actually should be avoided for json files, I am not sure why chrome puts them there, might need to have a look at the download code).
Long story short, I fixed to code to cope with files having BOMs. 60e2625