如何区分和解析像这样的字符串到json对象的数据:
"[{"months": 12, "product": "car"}, {"months": "12", "product": "bike"}]"
"[{"months": 12, "product": "car"}]"
我需要知道字符串中json对象的数量,并根据
获取值答案 0 :(得分:1)
json_string = '[{"product": "car", "months": 12}, {"product": "bike", "months": "12"}]'
import json
data = json.loads(json_string)
print data[0], len(data)