I have this JSON file:
https://drive.google.com/file/d/1zh_fJJNWs9GaPnlLZ459twSubsYkzMi5/view?usp=share_link
Looks normal at first, even using the online json schema validator However, when parsing it locally, I get an error. I tried with python, nodejs and golang but it doesn't work. I think it might have some hidden value that makes it impossible to parse it
This is the complete solution. Comments added to the code.
# read the file as bytes import chardet import json file_path=r"2022_2973.json" with open (file_path , "rb") as f: data= f.read() # read file as bytes file_encoding=chardet.detect(data)['encoding'] # detect the encoding print(f"file(bytes) encoding:{file_encoding}") # print encoding json_data = json.loads(data.decode(file_encoding)) # decode the bytes and load the json data json_data['snaps'][1]
Output:
file(bytes) encoding:UTF-16 {'group': 'Slot', 'group_order': 1, 'positions': [{'group': 'Slot', 'position': 'SLWR',
The above is the detailed content of An error occurred while parsing the JSON file, possibly a hidden value in the JSON content. For more information, please follow other related articles on the PHP Chinese website!