-7

["{\"contributors\": null, \"truncated\": false, \"text\": \"RT @itisprashanth: All petitions regarding #jallikattu to be heard by Supreme Court tomorrow. Tomorrow will be the D-Day for all the Youth\u2026\"}"]

  • What did you try? – T.Nel Mar 13 '18 at 09:53
  • Welcome to StackOverflow! Please read the info about [how to ask a good question](https://stackoverflow.com/help/how-to-ask) and [how to give a reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). This will make it much easier for others to help you. – Aditi Mar 13 '18 at 09:53

2 Answers2

2

use the json module to convert string to json object.

Ex:

import json
h = ["{\"contributors\": null, \"truncated\": false, \"text\": \"RT @itisprashanth: All petitions regarding #jallikattu to be heard by Supreme Court tomorrow. Tomorrow will be the D-Day for all the Youth\u2026\"}"]
for i in h:
    v = json.loads(i)
    print v["text"]

Output:

RT @itisprashanth: All petitions regarding #jallikattu to be heard by Supreme Court tomorrow. Tomorrow will be the D-Day for all the Youth…
Rakesh
  • 81,458
  • 17
  • 76
  • 113
1

Just parse the string (the first element of the given array) as a JSON object, and take its text value.

import json
arr = ["{"contributors": null, "truncated": false, "text": "RT @itisprashanth: All petitions regarding #jallikattu to be heard by Supreme Court tomorrow. Tomorrow will be the D-Day for all the Youth\u2026"}"]
print(json.loads(arr[0])["text"])
# "RT @itisprashanth: All petitions regarding #jallikattu to be heard by Supreme Court tomorrow. Tomorrow will be the D-Day for all the Youth\u2026"
speedstyle
  • 142
  • 4
  • 11