I am running into a parsing problem when loading JSON files that seem to have the TAB character in them.
当我转到http://jsonlint.com/时,我输入带有制表符的零件:
{
"My_String": "Foo bar. Bar foo."
}
The validator complains with:
Parse error on line 2:
{ "My_String": "Foo bar. Bar foo."
------------------^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['
这实际上是有问题的JSON文本的复制/粘贴.
I have tried loading this file with json
and simplejson
without success. How can I load this properly? Should I just pre-process the file and replace TAB by \t
or by a space? Or is there anything that I am missing here?
Update:
以下是simplejson
中的一个有问题的例子:
foo = '{"My_string": "Foo bar.\t Bar foo."}'
simplejson.loads(foo)
JSONDecodeError: Invalid control character '\t' at: line 1 column 24 (char 23)