Python Json

Asked 2 years ago, Updated 2 years ago, 42 views

{
"type":"push",
"targets":[
"stream",
"android",
"ios"
],
"push":{
"type":"sms_changed",
"source_device_iden":"ujzEgGbqE7UsjuPC94UrhA",
"notifications":[
{
"thread_id":"316",
"title": "Buye",
"body": "m",
"timestamp":1648564069
}
]
}
}

How do I extract "body" and "title" here?

python json

2022-09-20 10:56

1 Answers

Probably... I think we can do it 🤔 🤔

obj = {
  "type": "push",
  "targets": [
    "stream",
    "android",
    "ios"
  ],
  "push":{
    "type": "sms_changed",
    "source_device_iden": "ujzEgGbqE7UsjuPC94UrhA",
    "notifications": [{
        "thread_id": "316",
        "title": "Parent",
        "body": "m",
        "timestamp":1648564069
      }
    ]
  }
}

print(obj['push']['notifications'][0]['body']) #ㅁ


2022-09-20 10:56

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.