Home > Back-end >  Adding separate tweet data from JSON onto a List<String>
Adding separate tweet data from JSON onto a List<String>

Time:11-16

I've taken the following JSON example directly from Twitter's API example using Postman, my question is how would I be able to grab each tweets inside the "data" section and add each individual tweet onto a List < String > so that each individual tweet's sub JSON is saved as String in the List. Would this be possible? I was attempting to use the JSON parsing method decoding and encoding from Dart but that did not work, I'm not sure if its because the JSON example features the "data" section and the "errors" section. Any help would be greatly appreciated, thank you!

Example JSON:

{
  "data": [
    {
      "author_id": "12",
      "conversation_id": "20",
      "created_at": "2006-03-21T20:50:14.000Z",
      "id": "20",
      "text": "just setting up my twttr"
    },
    {
      "attachments": {
        "media_keys": [
          "16_1276500934466703361"
        ]
      },
      "author_id": "783214",
      "conversation_id": "1275244210439028736",
      "created_at": "2020-06-23T01:48:07.000Z",
      "entities": {
        "urls": [
          {
            "start": 112,
            "end": 135,
            "url": "https://twitter.com/Twitter/status/1275244210439028736/photo/1",
            "expanded_url": "https://twitter.com/Twitter/status/1275244210439028736/photo/1",
            "display_url": "pic.twitter.com/dpI2lRmj9F"
          }
        ]
      },
      "id": "1275244210439028736",
      "text": "Need to follow what’s happening in real time? Change your timeline to show latest Tweets instead of top Tweets."
    },
    {
      "attachments": {
        "media_keys": [
          "3_1274087263073255425"
        ]
      },
      "author_id": "783214",
      "conversation_id": "1274087687469715457",
      "created_at": "2020-06-19T21:12:32.000Z",
      "entities": {
        "mentions": [
          {
            "start": 13,
            "end": 22,
            "username": "YoliZama"
          }
        ],
        "urls": [
          {
            "start": 23,
            "end": 46,
            "url": "https://twitter.com/Twitter/status/1274087695145332736/photo/1",
            "expanded_url": "https://twitter.com/Twitter/status/1274087695145332736/photo/1",
            "display_url": "pic.twitter.com/lcGDLzAJIn"
          }
        ]
      },
      "id": "1274087695145332736",
      "referenced_tweets": [
        {
          "type": "replied_to",
          "id": "1274087694105075714"
        }
      ],
      "text": "           
  • Related