How would I get the json key names by doing a string split here? (Python) -


i have json var: [u'{"average_rating":3.75,"number_of_users_who_have_watched_this_movie":90,"title":"quiz show (1994)"}']

and want '3.75', '90' , 'quiz show (1994)'. i've tried doing:

  in var:       i.split(":")[1:-3] 

but it's not working. i'm sure simple don't how use properly! please help?

edit:

normally, use json library i'm using apache pyspark , there few issues around json - how can using string splitting?

you trying information json string, should use json this.

var = [u'{"average_rating":3.75,"number_of_users_who_have_watched_this_movie":90,"title":"quiz show (1994)"}'] import json  in var:     print json.loads(i)["average_rating"] 

per request of original poster:

var = [u'{"average_rating":3.75,"number_of_users_who_have_watched_this_movie":90,"title":"quiz show (1994)"}']  in var:     print(i.split(":")[1].split(",")[0]) 

Comments