Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6888629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:02:57+00:00 2026-05-27T06:02:57+00:00

I have this code import json from pprint import pprint json_data=open(‘bookmarks.json’) jdata = json.load(json_data)

  • 0

I have this code

import json
from pprint import pprint
json_data=open('bookmarks.json')
jdata = json.load(json_data)
pprint (jdata)
json_data.close()

How can I search through it for u'uri': u'http:?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:02:59+00:00Added an answer on May 27, 2026 at 6:02 am

    As json.loads simply returns a dict, you can use the operators that apply to dicts:

    >>> jdata = json.load('{"uri": "http:", "foo", "bar"}')
    >>> 'uri' in jdata       # Check if 'uri' is in jdata's keys
    True
    >>> jdata['uri']         # Will return the value belonging to the key 'uri'
    u'http:'
    

    Edit: to give an idea regarding how to loop through the data, consider the following example:

    >>> import json
    >>> jdata = json.loads(open ('bookmarks.json').read())
    >>> for c in jdata['children'][0]['children']:
    ...     print 'Title: {}, URI: {}'.format(c.get('title', 'No title'),
                                              c.get('uri', 'No uri'))
    ...
    Title: Recently Bookmarked, URI: place:folder=BOOKMARKS_MENU(...)
    Title: Recent Tags, URI: place:sort=14&type=6&maxResults=10&queryType=1
    Title: , URI: No uri
    Title: Mozilla Firefox, URI: No uri
    

    Inspecting the jdata data structure will allow you to navigate it as you wish. The pprint call you already have is a good starting point for this.

    Edit2: Another attempt. This gets the file you mentioned in a list of dictionaries. With this, I think you should be able to adapt it to your needs.

    >>> def build_structure(data, d=[]):
    ...     if 'children' in data:
    ...         for c in data['children']:
    ...             d.append({'title': c.get('title', 'No title'),
    ...                                      'uri': c.get('uri', None)})
    ...             build_structure(c, d)
    ...     return d
    ...
    >>> pprint.pprint(build_structure(jdata))
    [{'title': u'Bookmarks Menu', 'uri': None},
     {'title': u'Recently Bookmarked',
      'uri':   u'place:folder=BOOKMARKS_MENU&folder=UNFILED_BOOKMARKS&(...)'},
     {'title': u'Recent Tags',
      'uri':   u'place:sort=14&type=6&maxResults=10&queryType=1'},
     {'title': u'', 'uri': None},
     {'title': u'Mozilla Firefox', 'uri': None},
     {'title': u'Help and Tutorials',
      'uri':   u'http://www.mozilla.com/en-US/firefox/help/'},
     (...)
    }]
    

    To then “search through it for u'uri': u'http:'“, do something like this:

    for c in build_structure(jdata):
        if c['uri'].startswith('http:'):
            print 'Started with http'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code in my forms.py : from django import forms from formfieldset.forms
I have a simple tornado server running like this: import json import suds from
Say I have this code: #import <UIKit/UIKit.h> @interface MyView : UIView @end @implementation MyView
Let's say I have some code (using CherryPy) that looks like this: import cherrypy
I have this code: package graphics { import flash.display.Sprite; import flash.events.*; public class Ball
I have this code in jQuery, that I want to reimplement with the prototype
I have this code: chars = #some list try: indx = chars.index(chars) except ValueError:
I have this code that performs an ajax call and loads the results into
I have this code #include <iostream> using namespace std; int main(int argc,char **argv) {
I have this code: CCalcArchive::CCalcArchive() : m_calcMap() { } m_calcMap is defined as this:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.