0

I have python 2.7.6 installed and I need to parse the following json. I am bound to work with this version of python using no other external libraries.

{
  "entries": [
    {
      "author": {
        "value": "plugin-demo Administrator",
        "origin": "http://localhost:8080/webservice/person/18"
      },
      "creator": {
        "value": "plugin-demo Administrator",
        "origin": "http://localhost:8080/webservice/person/18"
      },
      "creationDate": "2015-11-04T15:14:18.000+0600",
      "lastModifiedDate": "2015-11-04T15:14:18.000+0600",
      "model": "http://localhost:8080/plugin-editorial/model/281/football",
      "payload": [
        {
          "name": "basic",
          "value": "Real Madrid are through"
        }
      ],
      "publishDate": "2015-11-04T15:14:18.000+0600"
    },
    {
      "author": {
        "value": "plugin-demo Administrator",
        "origin": "http://localhost:8080/webservice/person/18"
      },
      "creator": {
        "value": "plugin-demo Administrator",
        "origin": "http://localhost:8080/webservice/person/18"
      },
      "creationDate": "2015-11-04T15:14:18.000+0600",
      "lastModifiedDate": "2015-11-04T15:14:18.000+0600",
      "model": "http://localhost:8080/plugin-editorial/model/281/football",
      "payload": [
        {
          "name": "basic",
          "value": "Real Madrid are through"
        }
      ],
      "publishDate": "2015-11-04T15:14:18.000+0600"
    }
  ]
}

I want to access each json object in the json array. (e.g. entries[0], entries[1] etc...) How can I do that?

2 Answers 2

1

You can use the json module. It's been available since Python 2.6.

import json

jsonString= json.loads(string)
entries = jsonString['entries']

print entries[0]
print entries[1]
Sign up to request clarification or add additional context in comments.

Comments

0
import json

dictData = json.loads(strJsonString)

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.