0

I want to get particular value of a key such as agentName in below json format in python. How can this be done?

{
"metaData": {
    "fields": [
        "id",
        "path",
        "time",
        "userid",
        "type",
        "size",
        "lastProcessed",
        "numProcessed"
    ],
    "queueStatus": {
        "agentId": "publish-xxxxx",
        "agentName": "publish-xxxxx",
        "isBlocked": false,
        "isPaused": false,
        "lastProcessTime": -1,
        "nextRetryPeriod": -1524578525793,
        "processingSince": -1,
        "time": 1524578525792
    },
    "root": "queue"
},
"queue": []
}
3
  • What did you try? Commented Apr 24, 2018 at 14:18
  • 1
    k["metaData"]["queueStatus"]["agentName"] where k is your json dictionary. But you should really indicate what you have tried instead of asking people to just answer Commented Apr 24, 2018 at 14:20
  • Besides, the false and true should be False and True Commented Apr 24, 2018 at 14:21

1 Answer 1

1
d={'metaData': {'fields': ['id',
   'path',
   'time',
   'userid',
   'type',
   'size',
   'lastProcessed',
   'numProcessed'],
  'queueStatus': {'agentId': 'publish-xxxxx',
   'agentName': 'publish-xxxxx',
   'isBlocked': False,
   'isPaused': False,
   'lastProcessTime': -1,
   'nextRetryPeriod': -1524578525793L,
   'processingSince': -1,
   'time': 1524578525792L},
  'root': 'queue'},
 'queue': []}

#Code:
In [6]: d['metaData']['queueStatus']['agentName']
Out[6]: 'publish-xxxxx'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.