JSON解析valueerror - Python

时间:2015-12-01 11:08:19

标签: python json

我正在尝试解析有效​​的JSON文件并遇到以下错误。我也验证了我的JSON结构。

错误:

  parseJSON = json.loads(jsonFilePath);
  File "C:\Python34\lib\json\__init__.py", line 318, in loads
    return _default_decoder.decode(s)
  File "C:\Python34\lib\json\decoder.py", line 343, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Python34\lib\json\decoder.py", line 361, in raw_decode
    raise ValueError(errmsg("Expecting value", s, err.value)) from None
ValueError: Expecting value: line 1 column 1 (char 0)

代码:

vendorID = input('ENTER the vendor ID :');
jsonFilePath="C:/Users/user/Desktop/maradata.json";
parseJSON = json.loads(jsonFilePath);

我还在这里粘贴了JSON数据: http://pastecode.org/index.php/view/23471909

有人能建议我在哪里遇到错误吗?

1 个答案:

答案 0 :(得分:1)

加载 stringjson有两种方法:

  1. json.loads(s) s是字符串。
  2. json.load(fp) fp是文件指针。
相关问题