Access properties within a nested array of Google Fact Check API

Hello Thunkable Community,

I am working on a project that uses the Google Fact Check Tools API to retrieve fact-checking information. I’ve successfully made API requests and can parse and display some of the data. However, I’m encountering difficulties when trying to access nested arrays within the JSON response, specifically the ‘claimReview’ and ‘textualRating’ properties.

Examples of how the data is structured can be found at Fact Check (ClaimReview) Markup for Search | Google Search Central  |  Documentation  |  Google for Developers.

I need to extract the ‘title’ and ‘textualRating’ for each claim’s review. I attempted to loop through the ‘claims’ array and access the ‘claimReview’, but I’m either getting ‘null’ or incorrect values.

Here are the blocks I’m currently using:

Any suggestions on what blocks I should use or how to properly access the data within this nested array structure would be greatly appreciated.

Thank you!

I may be able to help you but in the meantime, I have a tutorial video that might be useful:

1 Like

I’m not finding the “claims” property in their example JSON response.

Can you post the full response you’re getting from the API as text? Be sure to format it using the </> button in the forums toolbar at the top of your post.

Thank you for linking that tutorial! It’s given me a couple of things to try.
Here’s the full response I get:

{
   "claims":[
      {
         "text":"Pictures show the Earth is flat, and sea levels haven’t changed",
         "claimant":"Social media",
         "claimDate":"2023-07-31T00:00:00Z",
         "claimReview":[
            {
               "publisher":{
                  "name":"USA Today",
                  "site":"usatoday.com"
               },
               "url":"https://www.usatoday.com/story/news/factcheck/2023/08/07/false-claim-the-earth-is-flat-and-sea-levels-arent-rising-fact-check/70533704007/",
               "title":"Pictures mislead: Ample evidence the Earth is round and sea levels ...",
               "reviewDate":"2023-08-07T21:38:36Z",
               "textualRating":"False",
               "languageCode":"en"
            }
         ]
      },
      {
         "text":"Satellites are fake.",
         "claimant":"instagram user",
         "claimDate":"2023-02-12T00:00:00Z",
         "claimReview":[
            {
               "publisher":{
                  "name":"Full Fact",
                  "site":"fullfact.org"
               },
               "url":"https://fullfact.org/online/earth-is-spherical-not-flat/",
               "title":"The Earth is not flat",
               "reviewDate":"2023-03-03T00:00:00Z",
               "textualRating":"There are many man-made satellites currently in orbit, playing an essential role in common electronic devices.",
               "languageCode":"en"
            }
         ]
      },
      {
         "text":"The Earth is flat.",
         "claimant":"instagram user",
         "claimDate":"2023-02-12T00:00:00Z",
         "claimReview":[
            {
               "publisher":{
                  "name":"Full Fact",
                  "site":"fullfact.org"
               },
               "url":"https://fullfact.org/online/earth-is-spherical-not-flat/",
               "title":"The Earth is not flat",
               "reviewDate":"2023-03-03T00:00:00Z",
               "textualRating":"We have abundant evidence going back thousands of years that the Earth is roughly spherical.",
               "languageCode":"en"
            }
         ]
      },
      {
         "text":"The Earth is flat because cities cannot be upside-down",
         "claimant":"Social media",
         "claimDate":"2022-11-22T00:00:00Z",
         "claimReview":[
            {
               "publisher":{
                  "name":"USA Today",
                  "site":"usatoday.com"
               },
               "url":"https://www.usatoday.com/story/news/factcheck/2022/12/13/fact-check-gravity-pulls-objects-toward-center-earth/10840434002/",
               "title":"Fact check: Gravity pulls objects toward the center of the Earth",
               "reviewDate":"2022-12-13T21:25:17Z",
               "textualRating":"False",
               "languageCode":"en"
            }
         ]
      },
      {
         "text":"Radar technology wouldn’t work if the Earth was a globe",
         "claimant":"Social media",
         "claimDate":"2023-04-20T00:00:00Z",
         "claimReview":[
            {
               "publisher":{
                  "name":"USA Today",
                  "site":"usatoday.com"
               },
               "url":"https://www.usatoday.com/story/news/factcheck/2023/05/08/no-radar-technology-doesnt-prove-earth-is-flat-fact-check/11728472002/",
               "title":"No, radar technology doesn't prove Earth is flat | Fact check",
               "reviewDate":"2023-05-08T23:13:06Z",
               "textualRating":"False",
               "languageCode":"en"
            }
         ]
      },
      {
         "text":"Video shows Elon Musk admitting he is a flat earther",
         "claimant":"Social media",
         "claimDate":"2023-04-22T00:00:00Z",
         "claimReview":[
            {
               "publisher":{
                  "name":"USA Today",
                  "site":"usatoday.com"
               },
               "url":"https://www.usatoday.com/story/news/factcheck/2023/04/28/fact-check-video-elon-musk-discussing-flat-earth-theory-altered/11728406002/",
               "title":"Fact check: Video of Elon Musk discussing flat Earth theory is altered",
               "reviewDate":"2023-04-28T13:59:26Z",
               "textualRating":"Altered",
               "languageCode":"en"
            }
         ]
      },
      {
         "text":"Image of Chicago skyline taken in Indiana proves Earth is flat",
         "claimant":"Social media",
         "claimDate":"2022-11-06T00:00:00Z",
         "claimReview":[
            {
               "publisher":{
                  "name":"USA Today",
                  "site":"usatoday.com"
               },
               "url":"https://www.usatoday.com/story/news/factcheck/2022/12/05/fact-check-image-chicago-skyline-proves-earth-round-not-flat/10664681002/",
               "title":"Fact check: Photo of the Chicago skyline from Indiana proves the ...",
               "reviewDate":"2022-12-05T21:05:48Z",
               "textualRating":"False",
               "languageCode":"en"
            }
         ]
      },
      {
         "text":"Laser tests show bodies of water are level, which proves the Earth is flat",
         "claimant":"Social media",
         "claimDate":"2022-11-27T00:00:00Z",
         "claimReview":[
            {
               "publisher":{
                  "name":"USA Today",
                  "site":"usatoday.com"
               },
               "url":"https://www.usatoday.com/story/news/factcheck/2022/12/07/fact-check-false-claim-laser-tests-prove-earth-flat/10821382002/",
               "title":"Fact check: False claim laser tests prove Earth is flat",
               "reviewDate":"2022-12-07T21:53:01Z",
               "textualRating":"False",
               "languageCode":"en"
            }
         ]
      },
      {
         "text":"Celestial navigation would be impossible if Earth is round, orbits the sun",
         "claimant":"Social media",
         "claimDate":"2024-02-22T00:00:00Z",
         "claimReview":[
            {
               "publisher":{
                  "name":"USA Today",
                  "site":"usatoday.com"
               },
               "url":"https://www.usatoday.com/story/news/factcheck/2024/03/05/no-navigation-by-ancients-does-not-show-earth-is-flat-fact-check/72835665007/",
               "title":"No, navigation by 'ancients' does not show Earth is flat | Fact check",
               "reviewDate":"2024-03-05T20:32:45Z",
               "textualRating":"False",
               "languageCode":"en"
            }
         ]
      },
      {
         "text":"Moon visible in the daytime proves Earth is flat",
         "claimant":"Social media",
         "claimDate":"2023-01-03T00:00:00Z",
         "claimReview":[
            {
               "publisher":{
                  "name":"USA Today",
                  "site":"usatoday.com"
               },
               "url":"https://www.usatoday.com/story/news/factcheck/2023/01/13/fact-check-false-claim-moon-visible-during-day-proof-flat-earth/11022360002/",
               "title":"Fact check: False claim moon visible during daytime is proof of flat ...",
               "reviewDate":"2023-01-13T21:54:51Z",
               "textualRating":"False",
               "languageCode":"en"
            }
         ]
      }
   ],
   "nextPageToken":"CAo"
}```

If it’s useful, I am working out of ‘HomeScreenListV2’ Thunkable

I think that when you are getting each item j of app variable JSON that result is JSON. But then you’re trying to get properties of the object j after that. Try adding a get object from JSON block in front of each j block inside your loop.

Then again, I can see a valid response from your existing blocks so maybe you just need the right combination of blocks to get the nested values. I can help with that but I’m not at my computer at the moment.

Paste your JSON into CodeBeautify and click on a property name to see the path to that property at the top of that website.

It’s something like claims[1].claimDetails[1].title

(Sorry, don’t have it in front of me so that’s from memory).

That site will show [0] for the first array/list item but Thunkable starts the list item count at 1.