LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 08-19-2012, 01:25 AM   #1
danoc93
LQ Newbie
 
Registered: May 2012
Posts: 19

Rep: Reputation: Disabled
How to read json files using python


I have a Json file that I download from the internet, as far as I know python has a library called json to handle these files.

I want for example to know the value of a field called "totalresults", how?

Or also to extract inner arrays... in java you can use jersey but I don't want to use that language.

Thanks a lot for the help.
 
Old 08-19-2012, 02:15 AM   #2
a4z
Member
 
Registered: Feb 2009
Posts: 329

Rep: Reputation: 127Reputation: 127
import json
data = json.load(open("filename))


data it than composed out of dictionaries and arrays
so for accessing data you need to read about dictionaries and arrays

start reading here
http://docs.python.org/library/json.html
and continue here
http://docs.python.org/tutorial/datastructures.html
and maybe some examples you can find via your favourite search engine
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
samba does not keep windows attributes (read only files as read only for example) golden_boy615 Linux - General 3 07-17-2011 06:44 PM
[SOLVED] Read content from net in python vbx_wx Programming 3 01-08-2011 01:46 AM
problem with python and yum... please read?!!!!! negrito211 Linux - Software 2 02-17-2009 10:13 AM
read lines in python horacioemilio Programming 2 12-04-2007 07:03 AM
mozzla problems-can not read files online, can not read attachments sarajevo Linux - Software 1 09-20-2005 06:58 PM


All times are GMT -5. The time now is 05:57 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration