Try to search your question here, if you can't find : Ask Any Question Now ?

python to parse json file

HomeCategory: stackoverflowpython to parse json file
Avatarpragati asked 4 weeks ago

i am new to python and json. I have a below json file in which i need to parse the “value” from the json file

{
  "link": [
    {
      "attributes": [
        {
          "value": "backup",
          "name": "name"
        },
        {
          "value": "",
          "name": "description"
        }
      ],

    },
    {
      "attributes": [
        {
          "value": "com.cap.blueprints",
          "name": "name"
        },
        {
          "value": "",
          "name": "description"
        }
      ],

    }
  ],
}

i have tried the below code. but i am getting error

with open ("respose_json.txt") as f2:
 data=json.load(f2)
 for x in data:
  print(x['attributes']['value']) 

error:
    print(x['attributes']['value']) 
TypeError: string indices must be integers
1 Answers
Best Answer
AvatarMannu answered 4 weeks ago
Your Answer

10 + 5 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com