Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I I have an array of json objects like this

[{"id":21,"username":"prerrit.kumar","email":"[email protected]","name":"Prerrit Kumar","bio":null,"skype":"","linkedin":"","twitter":"","theme_id":1,"color_scheme_id":1,"state":"active","created_at":"2013-09-26T11:40:02Z","extern_uid":null,"provider":null},{"id":22,"username":"aashish.arora","email":"[email protected]","name":"Aashish Arora","bio":null,"skype":"","linkedin":"","twitter":"","theme_id":1,"color_scheme_id":1,"state":"active","created_at":"2013-09-26T11:40:54Z","extern_uid":null,"provider":null}]

I would like to find a json object by the username and then find its id, I am new to python, I know the json.loads and have been able to get individual rows, but i think its not good from perf point of view to iterate one by one.

share|improve this question
 
You cannot search better than O(n) unless you're willing to sort by username first. –  xbonez Nov 1 at 8:39
 
Then you're out of options. –  Alexander Zhukov Nov 1 at 8:40
 
so you mean i can't query like xml queries with xml files –  Brij Raj Singh Nov 1 at 8:43
 
no, you can not as you can simply see. –  Andreas Jung Nov 1 at 8:44
3  
if you want faster search: throw your JSON into MongoDB –  Andreas Jung Nov 1 at 8:46
show 1 more comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.