How to parse json text data with python -


i need make request api of client, , api returns data:

[6,0,'vt3zrya',5,'usuezwa',5,0,0,0,0,0,4,0,0,0,2,0,0,3,0,0,0,0,2,0,1,["portale.titolari.client.config.shoulderdto/4121330600","java.util.hashset/3273092938","matteo sbragia","java.util.arraylist/4159755760","java.util.date/3385151746","matteo"],0,7] 

how can parse data , extract following fields :

matteo sbragia matteo 

i've tried code, it's not working :

data = json.load(output_data) pprint data 

this in fact not valid json string because contains single quotes '. can replace single quotes double quotes , parse string it's question whether intentional or mistake:

import json  s = '[6,0,\'vt3zrya\',5,\'usuezwa\',5,0,0,0,0,0,4,0,0,0,2,0,0,3,0,0,0,0,2,0,1,["portale.titolari.client.config.shoulderdto/4121330600","java.util.hashset/3273092938","matteo sbragia","java.util.arraylist/4159755760","java.util.date/3385151746","matteo"],0,7]'  data = json.loads(s.replace("\'", '"'))  print(data[26][2]) print(data[26][5]) 

prints:

$ python test.py  matteo sbragia matteo 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -