python - Parsing string containing possibly two json objects -
this question has answer here:
- parse json in python 4 answers
how differentiate , parse data strings json objects:
"[{"months": 12, "product": "car"}, {"months": "12", "product": "bike"}]" "[{"months": 12, "product": "car"}]"
i need know count of json objects in string , values based on that
use json
module
json_string = '[{"product": "car", "months": 12}, {"product": "bike", "months": "12"}]' import json data = json.loads(json_string) print data[0], len(data)
Comments
Post a Comment