in running a very simple code:
with open(json_file) as anno_file:
anno = json.load(anno_file)
, an error:
json. The decoder. JSONDecodeError: Extra data: line 1 column 57054 char (57053)
Reason 2.
according to the prompt, the reason should be the json file of each line there is a limit to the number character (not more than 57053), but my line too much content
>
>
>
>
>
>
>
with open(file_write, "w+") as f:
for infor in dict_w[index]:
dict_w1 = {infor: dict_w[index][infor]}
json.dump(dict_w1, f)
f.write("\n")
4. Further problems
run again at the beginning of reading and an error while reading code:
json. The decoder. JSONDecodeError: Extra data: line 2 column 1 (135) char
on. Load does not support decoding multiple JSON objects: Json. Loads code>, and
json. The load code>) does not decode multiple json object.
https://stackoverflow.com/questions/21058935/python-json-loads-shows-valueerror-extra-data
to fill: What are the JSON objects?
6. The solution of the problem further
way 1: put the object in a list to write again, and then load.
but in my practice, such a line of words too much, there will be 1 mentioned to
problem 2: read line by line, and add a list
Read More:
- Python common error: if using all scalar values, you must pass an index (four solutions)
- Build your own resnet18 network and load torch vision’s own weight
- R reads JSON data
- 13. R language: Error in match.names(clabs, names(xi)): The name is not relative to the original name
- 209151; org.json.JSONException A JSONObject text must begin with'{‘at character 1 of {
- Summary of three methods for pandas to convert dict into dataframe
- Mybatis uses step-by-step lazy loading to cause abnormal JSON conversion. The interface 500 reports an error
- Python’s json.loads Invalid control character
- ajax error 400 (Failed to load resource: the server responded with a status of 400 (Bad Request))
- Gulp failed to run
- Python keyerror exception
- Four ways to get Django parameters in request
- The sparse matrix of R language is too large to be used as.matrix
- The MySQL load data command parses and handles error 29 (errCode: 13) errors (in the Ubuntu environment)
- Pandas read_ Error in json() valueerror: training data
- How to Use the object of ES6 to clear the object value
- Error reading JSON file: json.decoder.JSONDecodeError : Extra data: line 6 column 2 (char 1329)
- Configuration file for vscode setting.json UI interface or JSON form
- vscode import numpy error:DLL load failed: The specific module could not be found
- The JSON object is converted into a formdata object, and the formdata object is converted into a JSON object