无法解析REST API调用中的JSON

Pra*_*een -1 python json

我无法从API调用中解析此JSON响应,我想提取板值(KA40M9202).

api_response = api_instance.recognize_bytes(params,...,...,...,...)

pprint (api_response)
Run Code Online (Sandbox Code Playgroud)

打印以下内容

{'results': [{'candidates': [{'confidence': 70.61698913574219,
                                  'matches_template': 0,
                                  'plate': 'KA40M9202'},
                                 {'confidence': 65.3728256225586,
                                  'matches_template': 0,
                                  'plate': 'KA30M9202'},
                                 {'confidence': 65.3718490600586,
                                  'matches_template': 0,
                                  'plate': 'KA10M9202'}],
                  'matches_template': 0,
                  'plate': 'KA40M9202',
                  'processing_time_ms': 39.60576629638672,
                  }
Run Code Online (Sandbox Code Playgroud)

在调用时json.loads(),会显示错误

jsonstr = json.loads(api_response)
Run Code Online (Sandbox Code Playgroud)

错误的消息

obj, end = self.raw_decode(s, idx=_w(s, 0).end())
TypeError: expected string or buffer
Run Code Online (Sandbox Code Playgroud)

L3v*_*han 5

PythonOpenALPR绑定recognize_所有返回开始

响应字典形式的OpenALPR分析

已经,所以没有必要解码JSON.

编辑:看起来文档字符串有点,它返回一个InlineResponse200对象,但它的.results属性将为您提供结果列表.