This is how Python and JSON works:
Either you save that exact content in a file and use:
with open('RelationshipRequest.json', 'r') as fh:
json_data = json.load(fh)
or you pass it as a string directly yourself:
json_data = json.loads('{ ... }')
Either way, the net result would be (and this is how you access JSON data):
for result in json_data['results']:
print(result['author']['objectId'])
Python doesn't treat JSON data as objects, like you're used to in JavaScript, it's a dictionary and nothing short of it so treat for what it is is my suggestion. There's probably some neat trick to convert this into class objects but this is generally how you actually use JSON data in Python.
Answer from Torxed on Stack Overflow
» pip install jsonpointer
What is jsonpointer?
Is jsonpointer popular?
Is jsonpointer safe to use?
This is how Python and JSON works:
Either you save that exact content in a file and use:
with open('RelationshipRequest.json', 'r') as fh:
json_data = json.load(fh)
or you pass it as a string directly yourself:
json_data = json.loads('{ ... }')
Either way, the net result would be (and this is how you access JSON data):
for result in json_data['results']:
print(result['author']['objectId'])
Python doesn't treat JSON data as objects, like you're used to in JavaScript, it's a dictionary and nothing short of it so treat for what it is is my suggestion. There's probably some neat trick to convert this into class objects but this is generally how you actually use JSON data in Python.
I don't fully understand what you want to accomplish, but if all you want is to extract the objectId fields, then the following code snippet will do that.
import json
with open('RelationshipRequest.json') as f:
json_data = json.load(f)
id_list = [rec['author']['objectId'] for rec in json_data['results']]
print id_list