python - Parsing string containing possibly two json objects -


this question has answer here:

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

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -