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 9293173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T21:04:12+00:00 2026-06-18T21:04:12+00:00

I have JSON that looks like this: { ROLE_NAME: { FOO: { download_url: http:

  • 0

I have JSON that looks like this:

{
"ROLE_NAME": {
    "FOO": {
        "download_url": "http: //something.staging/12345/buzz.zip"
    },
    "BAR": {
        "download_url": "http: //something.staging/12345/fizz.zip"
    },
    "download_url": "http: //something.staging/12345/fizzbuzz.zip",
    "db_name": "somedb",
    "db_server": "dbserver.staging.dmz",
    "plugin": {
        "server_url": "http: //lab.staging.corp/server/"
    }
}
}

I wrote a bit of python that replaces the “download_url” k:v with a new value (i.e. new download_url). Unfortunately it only replaces one of the three download_urls in that json snippet. I understand why, but am having a little difficulty getting the solution, and so I am here asking for help.

The entire json object is “data”
So I do something like this:

data["ROLE_NAME"]["download_url"] = download_url

Where download_url is a new value I have assigned to that variable
What I need to do is for any key called [“download_url”] then update it, rather than the one I have specified at the layer I am going to.

Some of my code to help:

I take some values obtained earlier in my code and build a url which returns a response. I extract a value from the response which will be used to build the value of download_url

buildinfo_url = "http://something.staging/guestAuth/app/rest/builds/?locator=buildType:%s,tags:%s,branch:branched:any" % (
    bt_number,
    list_json_load[role_name][0]['tag']
)

Send HTTP request

client = httplib2.Http()
response, xml = client.request(buildinfo_url)

Extract some value from the response xml and set download_url variable

doc = ElementTree.fromstring(xml)
for id in doc.findall('build'):
    build_id = "%s" % (id.attrib['id'])
try:
    download_url = "http://something.staging/guestAuth/repository/download/%s/%s:id/%s" % (
        bt_number,
        build_id,
        build_artifact_zip
    )
    data[role_name]["download_url"] = download_url
except NameError:
    print "something"

I think I should be recursively searching and updating

  • 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-06-18T21:04:14+00:00Added an answer on June 18, 2026 at 9:04 pm

    Using recursion

    import json   
    json_txt = """
    {
    "ROLE_NAME": {
        "FOO": {
            "download_url": "http: //something.staging/12345/buzz.zip"
        },
        "BAR": {
            "download_url": "http: //something.staging/12345/fizz.zip"
        },
        "download_url": "http: //something.staging/12345/fizzbuzz.zip",
        "db_name": "somedb",
        "db_server": "dbserver.staging.dmz",
        "plugin": {
            "server_url": "http: //lab.staging.corp/server/"
        }
    }
    }
    """
    data = json.loads(json_txt)
    
    def fixup(adict, k, v):
        for key in adict.keys():
            if key == k:
                adict[key] = v
            elif type(adict[key]) is dict:
                fixup(adict[key], k, v)
    
    import pprint
    pprint.pprint( data )
    
    fixup(data, 'download_url', 'XXX')
    
    pprint.pprint( data )
    

    Output:

    {u'ROLE_NAME': {u'BAR': {u'download_url': u'http: //something.staging/12345/fizz.zip'},
                    u'FOO': {u'download_url': u'http: //something.staging/12345/buzz.zip'},
                    u'db_name': u'somedb',
                    u'db_server': u'dbserver.staging.dmz',
                    u'download_url': u'http: //something.staging/12345/fizzbuzz.zip',
                    u'plugin': {u'server_url': u'http: //lab.staging.corp/server/'}}}
    {u'ROLE_NAME': {u'BAR': {u'download_url': 'XXX'},
                    u'FOO': {u'download_url': 'XXX'},
                    u'db_name': u'somedb',
                    u'db_server': u'dbserver.staging.dmz',
                    u'download_url': 'XXX',
                    u'plugin': {u'server_url': u'http: //lab.staging.corp/server/'}}}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a json structure that looks something like this: list:[ { type:link, href:http://google.com
I have a json object that looks something like this: Array ( [algorithm] =>
I have a JSON that looks something like this: var countries = [ {
I have a JSON string that looks something like this: {addresses:{address:[{@array:true,@id:888888,@uri:xyz,household:{@id:44444,@uri:xyz},person:{@id:,@uri:},addressType:{@id:1,@uri:xyz,name:Primary},address1:xyz,address2:null,address3:null,city:xyz,postalCode:111111}]}} What would be
I have a json document (as_stats.json) that looks something like this: {failed:5, received: {192.168.5.2:
I have JSON Object that looks something like the below object, this object can
I have JSON text that looks like this: { ok: true, totalPages: 256, arReports:
I have a JSON string that looks like this: { package1: { type: envelope,
Inside my .aspx I have some JSON code that looks like this: function someFunctionName()
I have to process JSON files that looks like this: \u0432\u043b\u0430\u0434\u043e\u043c <b>\u043f\u0443\u0442\u0438\u043c<\/b> \u043d\u0430\u0447 Unfortunately,

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.