I have a JSON that looks something like this:
[
{
"weburl": "https://google.com/athens",
"location": "Greece"
},
{
"weburl": "https://google.com/rome",
"location": "Italy"
}
...
]
What I want to do is create a function to pass this json into that
- Searches for the occurences of key "weburl" in the whole json, and
- calls urlparse(value).hostname to replace the string value next to the each of the "weburl" keys to only include hostname, and finally
- Return this entire modified json.
I'm having trouble doing this (particularly navigating through key,value and calling urlparse on the value) in Python, and any help would be appreciated!
Thanks.