Data questions (AirTable/JSON)

Hi all,

I am writing an App that first pulls data from an API with JSON structure and I have decided to use AirTable mainly because I can see the data that has been inserted when I view the table on Airtables site.

Whereas when I used the LocalDB option after inserting data, I am not able to see that data in the design screen.

Aside from this I wanted to ask the following about Airtable and API JSON.

  1. I make an API call and once this has been made it switches to another screen to view the data retrieved - I have found that on the first attempt at this there is no data, I then have to switch back and try again, this time data appears on the screen I switch to. So my question how to I best manage this delay in showing the data?
  2. When data is inserted from this JSON I am trying to use best practices to determine if the data already exists. So is there a method to attempt to update then insert if the update failes because the data does not exist?

Thank you

TimCS

I’m not an expert on APIs, but if you share your code block, we can try to identify why your application isn’t working

@ozel1978 Thank you for your reply - its not that my app is not working I have just found that I have to put a delay before the screen switches between the request of the API/JSON and where it updates /creates the row - clearly the API is not responding quickly enough to the request by the looks of it

Still trying to work on the best practice for the handling of data fed into the database

1 Like

I have tried to use the "List of Values in block to search for the name from the JSON file that may exist in the table - however it seems to have only worked for one record .

I presume this is because that was the first record that matched up but does not search all of the records at once for another match.

So I am trying to find a way to look for the name field in the JSON file that matches the name in the database table and if it exists do not add otherwise add this record.

Any ideas the best way to do this? I was thinking of using the Test block but unsure how to use this to compare the fields in a loop

Thanks

TimCS

You’ll need to post the full JSON response you’re getting from the API as text and use the </> button in the toolbar to format it (which removes smart quotes).

Without seeing the JSON, it’s almost impossible to answer your question about how to parse it.

I do have a tutorial that may be of help: API JSON Tutorial (Video)

@tatiang Hello again - thank you for your reply - just an insight this is the same JSON file we looked at before with Google places.

I have a thought on this and wondered if you could help out - there is a block under data sources which is called "list values in

" could I load this into a list and then search on the list to see if the values from the JSON file already exist?

If so how would I load the values into the list ? I think if I can achieve this I should be able to search inside the list to see if the name value from the JSON already exists.

Thank you

TimCS

Sorry, I can’t answer that without seeing the JSON again. Every JSON response is uniquely structured so there is no “one size fits all” answer.

{ “html_attributions” : , “results” : [ { “business_status” : “OPERATIONAL”, “geometry” : { “location” : { “lat” : 52.4074308, “lng” : 0.2480165 }, “viewport” : { “northeast” : { “lat” : 52.40882232989272, “lng” : 0.2496061298927222 }, “southwest” : { “lat” : 52.40612267010728, “lng” : 0.2469064701072778 } } }, “icon” : “https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/generic_business-71.png”, “icon_background_color” : “#7B9EB0”, “icon_mask_base_uri” : “https://maps.gstatic.com/mapfiles/place_api/icons/v2/generic_pinlet”, “name” : “The Hive Leisure Centre”, “opening_hours” : { “open_now” : true }, “photos” : [ { “height” : 5289, “html_attributions” : [ “\u003ca href="Google Maps”\u003eA Google User\u003c/a\u003e" ], “photo_reference” : “AWYs27zdER5JwIkyeTLhiDrzrMqgyqFkMiaLZL1J-Tp-wY7cfBUKbxwCWIOMf46KseiM98Ry5mwYS-ZJj_7G4KgvpagyaD7SkDtrDFpya9B4Qy0VJjnLVp8KSpxfqLlvtVihFUKDA5l6RoAAVFuzpZSDjWRbT_u3zadltMmu-gbRFf6CvKEb”, “width” : 7929 } ], “place_id” : “ChIJteaDQS8T2EcR7VOKu37W_0k”, “plus_code” : { “compound_code” : “C64X+X6 Ely”, “global_code” : “9F42C64X+X6” }, “rating” : 4, “reference” : “ChIJteaDQS8T2EcR7VOKu37W_0k”, “scope” : “GOOGLE”, “types” : [ “gym”, “point_of_interest”, “health”, “establishment” ], “user_ratings_total” : 488, “vicinity” : “Leisure Park, 15 Downham Rd, Ely” }, { “business_status” : “OPERATIONAL”, “geometry” : { “location” : { “lat” : 52.3973117, “lng” : 0.2486357 }, “viewport” : { “northeast” : { “lat” : 52.39878827989272, “lng” : 0.2498862798927222 }, “southwest” : { “lat” : 52.39608862010728, “lng” : 0.2471866201072778 } } }, “icon” : “https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/generic_business-71.png”, “icon_background_color” : “#7B9EB0”, “icon_mask_base_uri” : “https://maps.gstatic.com/mapfiles/place_api/icons/v2/generic_pinlet”, “name” : “Play Area”, “opening_hours” : { “open_now” : true }, “photos” : [ { “height” : 1080, “html_attributions” : [ “\u003ca href="Google Maps ], “photo_reference” : “AWYs27yXBQbmuLiZE6cJ3XaglcZj-QtrQhDot4MKYJeVZJiQpy2gvzXqwGmv2wVDFdMspksIzY061-WdyjhUDk-iX6SFD2fAZ01AGM3X13lY9LBUqt4jmLlcgZ0HUrsekk_uFqBcuy2wEXM8lznJmQAaNRwowu7yOJKPgnYWlNIc97wkEutN”, “width” : 1920 } ], “place_id” : “ChIJ34vOnvcT2EcRZSsWoUJiv8s”, “plus_code” : { “compound_code” : “96WX+WF Ely”, “global_code” : “9F4296WX+WF” }, “rating” : 4.7, “reference” : “ChIJ34vOnvcT2EcRZSsWoUJiv8s”, “scope” : “GOOGLE”, “types” : [ “point_of_interest”, “establishment” ], “user_ratings_total” : 3, “vicinity” : “St John’s Rd, Ely” }, { “business_status” : “OPERATIONAL”, “geometry” : { “location” : { “lat” : 52.39752499999999, “lng” : 0.2706318 }, “viewport” : { “northeast” : { “lat” : 52.39892002989272, “lng” : 0.2720447798927221 }, “southwest” : { “lat” : 52.39622037010727, “lng” : 0.2693451201072776 } } }, “icon” : “https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/generic_business-71.png”, “icon_background_color” : “#7B9EB0”, “icon_mask_base_uri” : “https://maps.gstatic.com/mapfiles/place_api/icons/v2/generic_pinlet”, “name” : “Willow Park Play Area”, “photos” : [ { “height” : 3264, “html_attributions” : [ “\u003ca href="Google Maps”\u003eMaryna Kuzmenko\u003c/a\u003e” ], “photo_reference” : “AWYs27wfEgxOq9B32ESQzeCSAphTHM3NLRgZgm6E4EHrjHc-VtEuG8Rkmhs0F8taVAINo66_rZ9FeQYdjGCmyScmrwLtxEJzukiNoWzyHXUyCgtSeI5yQZWX_ivERh08YjnBd9uIqtqJmodcn9dSYZNlsQbU6xgxCfG88rbbcFIS0fS_grl2”, “width” : 2448 } ], “place_id” : “ChIJwbXrZIIT2EcRc3iC49CI0iA”, “plus_code” : { “compound_code” : “97XC+27 Ely”, “global_code” : “9F4297XC+27” }, “rating” : 4.8, “reference” : “ChIJwbXrZIIT2EcRc3iC49CI0iA”, “scope” : “GOOGLE”, “types” : [ “point_of_interest”, “establishment” ], “user_ratings_total” : 8, “vicinity” : “22 Willow Walk, Ely” }, { “business_status” : “OPERATIONAL”, “geometry” : { “location” : { “lat” : 52.4011761, “lng” : 0.2658394 }, “viewport” : { “northeast” : { “lat” : 52.40250842989273, “lng” : 0.2672332798927222 }, “southwest” : { “lat” : 52.39980877010728, “lng” : 0.2645336201072777 } } }, “icon” : “https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/cafe-71.png”, “icon_background_color” : “#FF9E67”, “icon_mask_base_uri” : “https://maps.gstatic.com/mapfiles/place_api/icons/v2/cafe_pinlet”, “name” : “The Yard - by Silver Oak”, “opening_hours” : { “open_now” : true }, “photos” : [ { “height” : 3468, “html_attributions” : [ “\u003ca href="Google Maps”\u003eNigel Warner\u003c/a\u003e" ], “photo_reference” : “AWYs27wNePqd5E2G–sGSYhj7pGJRPR9sA3HQYijLQ7lBBMAwgcz9qYNJ7UbqlmIA5oGwDPGqEWmfocYrnksWcZaAmjp-VaVECTxYviG4YPJs6jWue3lTEbbcMwSg_Dm6hQiVv47i4-tlUCLSbzZB1aliNls4_X4p8NVhkcqPFgK4HZ1Dsqg”, “width” : 4624 } ], “place_id” : “ChIJ6wGTOzsT2EcRsfRIJMRj2P4”, “plus_code” : { “compound_code” : “C728+F8 Ely”, “global_code” : “9F42C728+F8” }, “price_level” : 2, “rating” : 4.6, “reference” : “ChIJ6wGTOzsT2EcRsfRIJMRj2P4”, “scope” : “GOOGLE”, “types” : [ “cafe”, “bar”, “restaurant”, “point_of_interest”, “food”, “establishment” ], “user_ratings_total” : 365, “vicinity” : “35A Newnham St, Ely” }, { “business_status” : “OPERATIONAL”, “geometry” : { “location” : { “lat” : 52.39920249999999, “lng” : 0.2460437 }, “viewport” : { “northeast” : { “lat” : 52.40048507989272, “lng” : 0.2473468298927222 }, “southwest” : { “lat” : 52.39778542010727, “lng” : 0.2446471701072777 } } }, “icon” : “https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/generic_business-71.png”, “icon_background_color” : “#7B9EB0”, “icon_mask_base_uri” : “https://maps.gstatic.com/mapfiles/place_api/icons/v2/generic_pinlet”, “name” : “Darwin Close Play Area”, “opening_hours” : { “open_now” : true }, “place_id” : “ChIJdRr4r9AT2EcRrGTvTWwXPQ0”, “plus_code” : { “compound_code” : “96XW+MC Ely”, “global_code” : “9F4296XW+MC” }, “rating” : 0, “reference” : “ChIJdRr4r9AT2EcRrGTvTWwXPQ0”, “scope” : “GOOGLE”, “types” : [ “point_of_interest”, “establishment” ], “user_ratings_total” : 0, “vicinity” : “22 Darwin Cl, Ely” } ], “status” : “OK”}

Here a version of the JSON however I could not see the </> button in the toolbar here to format it sorry

{
   "html_attributions" : [],
   "results" : 
   [
      {
         "business_status" : "OPERATIONAL",
         "geometry" : 
         {
            "location" : 
            {
               "lat" : 52.4074308,
               "lng" : 0.2480165
            },
            "viewport" : 
            {
               "northeast" : 
               {
                  "lat" : 52.40882232989272,
                  "lng" : 0.2496061298927222
               },
               "southwest" : 
               {
                  "lat" : 52.40612267010728,
                  "lng" : 0.2469064701072778
               }
            }
         },
         "icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/generic_business-71.png",
         "icon_background_color" : "#7B9EB0",
         "icon_mask_base_uri" : "https://maps.gstatic.com/mapfiles/place_api/icons/v2/generic_pinlet",
         "name" : "The Hive Leisure Centre",
         "opening_hours" : 
         {
            "open_now" : true
         },
         "photos" : 
         [
            {
               "height" : 5289,
               "html_attributions" : 
               [
                  "\u003ca href=\"https://maps.google.com/maps/contrib/100487243346731320246\"\u003eA Google User\u003c/a\u003e"
               ],
               "photo_reference" : "AWYs27ywUVqEwmv5r503O6cw4T4gvtD-_wFY5gBWVBwhxJgMTvJlYg7Hlaewli1MMximR1o6CUzGerQTVcEJ698sh_8aRdQK9uPj36Mgml0bHk-UIWkmXKk5R3xK5itJWtryaxNDL5U9g5h9oQGquTB5z5-v0VUaEzdz7jpP5ks9bSzWZS0E",
               "width" : 7929
            }
         ],
         "place_id" : "ChIJteaDQS8T2EcR7VOKu37W_0k",
         "plus_code" : 
         {
            "compound_code" : "C64X+X6 Ely",
            "global_code" : "9F42C64X+X6"
         },
         "rating" : 4,
         "reference" : "ChIJteaDQS8T2EcR7VOKu37W_0k",
         "scope" : "GOOGLE",
         "types" : 
         [
            "gym",
            "health",
            "point_of_interest",
            "establishment"
         ],
         "user_ratings_total" : 488,
         "vicinity" : "Leisure Park, 15 Downham Rd, Ely"
      },
      {
         "business_status" : "OPERATIONAL",
         "geometry" : 
         {
            "location" : 
            {
               "lat" : 52.3956756,
               "lng" : 0.2413361
            },
            "viewport" : 
            {
               "northeast" : 
               {
                  "lat" : 52.39706472989272,
                  "lng" : 0.2426566298927223
               },
               "southwest" : 
               {
                  "lat" : 52.39436507010728,
                  "lng" : 0.2399569701072778
               }
            }
         },
         "icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/generic_business-71.png",
         "icon_background_color" : "#7B9EB0",
         "icon_mask_base_uri" : "https://maps.gstatic.com/mapfiles/place_api/icons/v2/generic_pinlet",
         "name" : "Murfit Close Play Area",
         "opening_hours" : 
         {
            "open_now" : true
         },
         "place_id" : "ChIJk3o5JGET2EcRlXyEOySEDHI",
         "plus_code" : 
         {
            "compound_code" : "96WR+7G Ely",
            "global_code" : "9F4296WR+7G"
         },
         "rating" : 4.3,
         "reference" : "ChIJk3o5JGET2EcRlXyEOySEDHI",
         "scope" : "GOOGLE",
         "types" : 
         [
            "point_of_interest",
            "establishment"
         ],
         "user_ratings_total" : 8,
         "vicinity" : "9 Morley Dr, Ely"
      },
      {
         "business_status" : "OPERATIONAL",
         "geometry" : 
         {
            "location" : 
            {
               "lat" : 52.3973117,
               "lng" : 0.2486357
            },
            "viewport" : 
            {
               "northeast" : 
               {
                  "lat" : 52.39878827989272,
                  "lng" : 0.2498862798927222
               },
               "southwest" : 
               {
                  "lat" : 52.39608862010728,
                  "lng" : 0.2471866201072778
               }
            }
         },
         "icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/generic_business-71.png",
         "icon_background_color" : "#7B9EB0",
         "icon_mask_base_uri" : "https://maps.gstatic.com/mapfiles/place_api/icons/v2/generic_pinlet",
         "name" : "Play Area",
         "opening_hours" : 
         {
            "open_now" : true
         },
         "photos" : 
         [
            {
               "height" : 1080,
               "html_attributions" : 
               [
                  "\u003ca href=\"https://maps.google.com/maps/contrib/101699236731014143122\"\u003ePaulPeeling\u003c/a\u003e"
               ],
               "photo_reference" : "AWYs27wju9I0DK95bEeQz3G9u_LPcPeW05xZTXdGNoeCMK1ckxnc5c3L3lodoOPjiAW7BfkOEt1PVgDecRab_kjXyd5ytFjjm_NmVH_Gq_WUpmZ9YTVwmBmA2LF8Kj0C0bSQkZnNAOrzVGt16zHBBsdk9e1ch30pvgzF1xapkjx6y2IEr0gV",
               "width" : 1920
            }
         ],
         "place_id" : "ChIJ34vOnvcT2EcRZSsWoUJiv8s",
         "plus_code" : 
         {
            "compound_code" : "96WX+WF Ely",
            "global_code" : "9F4296WX+WF"
         },
         "rating" : 4.7,
         "reference" : "ChIJ34vOnvcT2EcRZSsWoUJiv8s",
         "scope" : "GOOGLE",
         "types" : 
         [
            "point_of_interest",
            "establishment"
         ],
         "user_ratings_total" : 3,
         "vicinity" : "St John's Rd, Ely"
      },
      {
         "business_status" : "OPERATIONAL",
         "geometry" : 
         {
            "location" : 
            {
               "lat" : 52.39752499999999,
               "lng" : 0.2706318
            },
            "viewport" : 
            {
               "northeast" : 
               {
                  "lat" : 52.39892002989272,
                  "lng" : 0.2720447798927221
               },
               "southwest" : 
               {
                  "lat" : 52.39622037010727,
                  "lng" : 0.2693451201072776
               }
            }
         },
         "icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/generic_business-71.png",
         "icon_background_color" : "#7B9EB0",
         "icon_mask_base_uri" : "https://maps.gstatic.com/mapfiles/place_api/icons/v2/generic_pinlet",
         "name" : "Willow Park Play Area",
         "photos" : 
         [
            {
               "height" : 4000,
               "html_attributions" : 
               [
                  "\u003ca href=\"https://maps.google.com/maps/contrib/117195311587241358828\"\u003eEhsaan Khan\u003c/a\u003e"
               ],
               "photo_reference" : "AWYs27zTmkdArpAsMHHps6pwCUq5XDXPbwYxS5zQMX72zVVP8MMfuIjIDB57FiEDiGk0U8DHN3ahRCF7CqMYzDqyeJk7J_JJebEitZ2v6ekUEgrJmUb03MWVRcBiz31pAyvxi5UKOtkp7W2txDnMtjQUt2A2A9pWZsOIHjuRQAMr09j6p7mk",
               "width" : 1800
            }
         ],
         "place_id" : "ChIJwbXrZIIT2EcRc3iC49CI0iA",
         "plus_code" : 
         {
            "compound_code" : "97XC+27 Ely",
            "global_code" : "9F4297XC+27"
         },
         "rating" : 4.8,
         "reference" : "ChIJwbXrZIIT2EcRc3iC49CI0iA",
         "scope" : "GOOGLE",
         "types" : 
         [
            "point_of_interest",
            "establishment"
         ],
         "user_ratings_total" : 8,
         "vicinity" : "22 Willow Walk, Ely"
      },
      {
         "business_status" : "OPERATIONAL",
         "geometry" : 
         {
            "location" : 
            {
               "lat" : 52.4011761,
               "lng" : 0.2658394
            },
            "viewport" : 
            {
               "northeast" : 
               {
                  "lat" : 52.40250842989273,
                  "lng" : 0.2672332798927222
               },
               "southwest" : 
               {
                  "lat" : 52.39980877010728,
                  "lng" : 0.2645336201072777
               }
            }
         },
         "icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/cafe-71.png",
         "icon_background_color" : "#FF9E67",
         "icon_mask_base_uri" : "https://maps.gstatic.com/mapfiles/place_api/icons/v2/cafe_pinlet",
         "name" : "The Yard - by Silver Oak",
         "opening_hours" : 
         {
            "open_now" : false
         },
         "photos" : 
         [
            {
               "height" : 3468,
               "html_attributions" : 
               [
                  "\u003ca href=\"https://maps.google.com/maps/contrib/115960785494722888837\"\u003eNigel Warner\u003c/a\u003e"
               ],
               "photo_reference" : "AWYs27y58k6k3Bobeb-ZR-JpgWuAPPkWvHNNUiWAU1j8t-aWB3QzJ8vh0j0IJ-a_49Z5y6WDVjn1CY8vbxiRIeWPyDql4o057Bo-3BidDKlZcWpqwM20lKZOiwORiL-RCU-f_NHxGM5Ayldp2ZpEkpYC2YwyWqD_RxWIiU7Bxw5pxynt_JP7",
               "width" : 4624
            }
         ],
         "place_id" : "ChIJ6wGTOzsT2EcRsfRIJMRj2P4",
         "plus_code" : 
         {
            "compound_code" : "C728+F8 Ely",
            "global_code" : "9F42C728+F8"
         },
         "price_level" : 2,
         "rating" : 4.6,
         "reference" : "ChIJ6wGTOzsT2EcRsfRIJMRj2P4",
         "scope" : "GOOGLE",
         "types" : 
         [
            "cafe",
            "bar",
            "restaurant",
            "food",
            "point_of_interest",
            "establishment"
         ],
         "user_ratings_total" : 368,
         "vicinity" : "35A Newnham St, Ely"
      },
      {
         "business_status" : "OPERATIONAL",
         "geometry" : 
         {
            "location" : 
            {
               "lat" : 52.39920249999999,
               "lng" : 0.2460437
            },
            "viewport" : 
            {
               "northeast" : 
               {
                  "lat" : 52.40048507989272,
                  "lng" : 0.2473468298927222
               },
               "southwest" : 
               {
                  "lat" : 52.39778542010727,
                  "lng" : 0.2446471701072777
               }
            }
         },
         "icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/generic_business-71.png",
         "icon_background_color" : "#7B9EB0",
         "icon_mask_base_uri" : "https://maps.gstatic.com/mapfiles/place_api/icons/v2/generic_pinlet",
         "name" : "Darwin Close Play Area",
         "opening_hours" : 
         {
            "open_now" : true
         },
         "place_id" : "ChIJdRr4r9AT2EcRrGTvTWwXPQ0",
         "plus_code" : 
         {
            "compound_code" : "96XW+MC Ely",
            "global_code" : "9F4296XW+MC"
         },
         "rating" : 0,
         "reference" : "ChIJdRr4r9AT2EcRrGTvTWwXPQ0",
         "scope" : "GOOGLE",
         "types" : 
         [
            "point_of_interest",
            "establishment"
         ],
         "user_ratings_total" : 0,
         "vicinity" : "22 Darwin Cl, Ely"
      },
      {
         "business_status" : "OPERATIONAL",
         "geometry" : 
         {
            "location" : 
            {
               "lat" : 52.3988018,
               "lng" : 0.2722476
            },
            "viewport" : 
            {
               "northeast" : 
               {
                  "lat" : 52.39993807989272,
                  "lng" : 0.2739633298927223
               },
               "southwest" : 
               {
                  "lat" : 52.39723842010728,
                  "lng" : 0.2712636701072778
               }
            }
         },
         "icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/shopping-71.png",
         "icon_background_color" : "#4B96F3",
         "icon_mask_base_uri" : "https://maps.gstatic.com/mapfiles/place_api/icons/v2/shoppingcart_pinlet",
         "name" : "Sainsbury's",
         "opening_hours" : 
         {
            "open_now" : true
         },
         "photos" : 
         [
            {
               "height" : 3968,
               "html_attributions" : 
               [
                  "\u003ca href=\"https://maps.google.com/maps/contrib/103564429436242135875\"\u003eNatasha Biggs\u003c/a\u003e"
               ],
               "photo_reference" : "AWYs27x_7kEet9gGmhwCwl3LIFrX1sww-_j7-0nj2NIt2yPnd69xhZFqWcirKOTfrumlV5i3ZOUeNx6eDZ_nJXjV9q7H2L59LIdqtJgPByO3t7eaGyW3xLcWY2yjigAi7G_NJpWNlKht8ncHKLd6yK0lOGJpdclxVg9ScYZPmtlIZKfA8gVB",
               "width" : 2976
            }
         ],
         "place_id" : "ChIJBdc1-XMT2EcRCrAYt-Gewd8",
         "plus_code" : 
         {
            "compound_code" : "97XC+GV Ely",
            "global_code" : "9F4297XC+GV"
         },
         "price_level" : 2,
         "rating" : 4.3,
         "reference" : "ChIJBdc1-XMT2EcRCrAYt-Gewd8",
         "scope" : "GOOGLE",
         "types" : 
         [
            "supermarket",
            "grocery_or_supermarket",
            "bakery",
            "food",
            "point_of_interest",
            "store",
            "establishment"
         ],
         "user_ratings_total" : 2098,
         "vicinity" : "Lisle Ln, Ely"
      }
   ],
   "status" : "OK"
}

Here is a better version of it

1 Like

It’s here when composing or editing a post:

(I already formatted your second JSON post using that button.)

Alright, so next question:

Which value(s) are you trying to get? If you post the formatted JSON text into Best JSON Viewer and JSON Beautifier Online, you’ll see a “tree” and you can click on a value to see the path to that value at the top:

For example, to get the highlighted property “lat”, I would get property “results[1].geometry.location.lat” of object (where object is the object generated from the JSON response in Thunkable). I have to use 1 for the array/list index because Thunkable starts lists at index=1 whereas JSON arrays (aka lists) start at index=0.

@tatiang thanks for your reply i think i haven’t been clear about what I’m trying to achieve sorry about this.

I can access the json data as per your method and another method that I’ve used after following your video tutorial which have been very helpful. However I’m taking the name vicinity tatibg long lat at this stage from this data, what in trying to do is make sure the data doesn’t get duplicated when written to by airtable database

So I’m using the nane field from the json data to lookup in my database but I’m struggling to get it to work

I think my first problem is how to loop through my JSON data - I can pull out a single record using this way:

But my issue is how to loop through the JSON data - I tried the For each item in list but this does not seem to work (I have removed any IF conditions at the moment) as no records are being added to the Airtable so I think this is how I cam calling the JSON data . The DataFromAPI was defined with the get object from JSON block against the response but I have also tried this loop with a var that takes the response without this block as well.

Would someone please provide an example on how to do this?

One problem is that you set a variable to the object generated from JSON but then used the variable containing the JSON instead of the one containing the object:

The multiple instances of app variable DataFromAPI in your screenshots should be app variable GetJSONData instead. It might clarify things to rename that variable to something like “Object of DataFromAPI”

@tatiang Sorry please ignore that reference from GetJSONdata to DataFromAPI I was trying something out there - the DataFromAPI has already been “converted” using that same method via the Response API Var beforehand

Also note that the call to pull the single record using DataFromAPI did work it is just the loop call that does not work

My question is, am I going about the Loop method correctly ?

No. Your logic is correct but the blocks you chose won’t work. The for each item in list block returns a list item j but you’re then trying to get the list item #j from the list. A list item # has to be an integer… it can’t be anything else.

You need to instead get the property “results.name” of object j and then “results.vicinity” of object j, etc. I prefer to use a single get property of object block for that but if you’d rather, you can use multiple as in your screenshot.

@tatiang Thank you for your reply - I am little lost here sorry - do you mind if you could provide examples of both methods that you have mentioned?

Sure! It’s confusing stuff. Took me a long time to understand. I still have to think it through several times when I’m trying to do this.

I would set it up like this:

If that fails to create a row, then do a test by setting a label’s text to one of the get property of object blocks within the loop. You may need a longer delay than 0.25 seconds to be able to see if the properties are being retrieved correctly.

@tatiang Ok well that has created records however oddly enough it appears to have duplicated a lot of the same data and even if I increase the wait it seems to do this.

Also why is a wait required as when this screen opens the user can see see the records being added one at a time.

So the API call is made on one screen - then that opens this data screen to show the results by a image click

Ah I think I know the cause of the duplicates but its A) how to get around this and B) to also stop future duplicates from happening each time the image click is triggered to show / add any records to the datalist view

The cause is done to the location were the creation of records is being called - this is in the screens Open block and also I presume some how when the datalist view is being refreshed (although there is no trigger for this within the datalist view)

Thanks

TimCS

1 Like