How do i mass update table using json response given by my api?

How do i mass update table using json response given by my api?

I am trying to update a database i'm making in creator once a day using an api call to my current crm which i cant stop using. the api will respond with a json file containing 500 contacts with 2-3 layers of information on each contact. i'm going to have to do this 15+ times to fully sync my zoho database with my crm.  So far i've used Deluge to get an access token and use said access token to get large json file full of contact information. Bellow i've added 2 of many contacts in the json file. What i need is to take the json file i received in my response and 1)if the contact exists update it (if its changed) 2) if file doesnt exists then ad it.

SAMPLE JSON
{  "TotalCount": 6787,
"Data": [
  {
    "Location": {
      "Id": 9545707,
      "Name": "Primary"
    },
    "Customer": {
      "Inactive": false,
      "Id": 8873547,
      "Name": "John Ashley"
    },
    "FirstName": "John",
    "LastName": "Ashley",
    "PhoneNumber": "",
    "PhoneNumber2": "777777777",
    "Email": "email",
    "Title": "",
    "Fax": "",
    "Notes": "",
    "Id": 9342900,
    "Metadata": {
      "CreatedBy": "email",
      "CreatedOn": "2020-04-30T17:40:39",
      "UpdatedOn": "2020-04-30T17:40:39",
      "UpdatedBy": "email",
      "Version": 1
    },
    "ExternalSystemId": null
  },
  {
    "Location": {
      "Id": 9545829,
      "Name": "adress"
    },
    "Customer": {
      "Inactive": false,
      "Id": 8873674,
      "Name": "Ename"
    },
    "FirstName": "fname",
    "LastName": "lname",
    "PhoneNumber": "",
    "PhoneNumber2": "7777777",
    "Email": "email",
    "Title": "",
    "Fax": "",
    "Notes": "",
    "Id": 9343021,
    "Metadata": {
      "CreatedBy": "email",
      "CreatedOn": "2020-04-30T16:04:23",
      "UpdatedOn": "2020-04-30T16:04:23",
      "UpdatedBy": "email",
      "Version": 1
    },
    "ExternalSystemId": null
  },
  {
    "Location": {
      "Id": 9546128,
      "Name": "Primary"
    },
    "Customer": {
      "Inactive": false,
      "Id": 8873966,
      "Name": "name"
    },
    "FirstName": "fname",
    "LastName": "lname",
    "PhoneNumber": "",
    "PhoneNumber2": "7777777777",
    "Email": "email",
    "Title": "",
    "Fax": "",
    "Notes": "",
    "Id": 9343319,
    "Metadata": {
      "CreatedBy": "email",
      "CreatedOn": "2020-04-30T18:38:02",
      "UpdatedOn": "2020-04-30T18:38:02",
      "UpdatedBy": "email",
      "Version": 1
    },
    "ExternalSystemId": null 
  }}]} 
**Code i've written so far**(this code doesnt work after second "insert into contact table", on top of that it doesnt update it just adds new lines )


   jsonVar = getUrl("https://cloud.servicebridge.com/api/v1.1/Contacts?pageSize=500&sessionKey=" + APIKEY);
DataVar = jsonVar.getJSON("Data");
DataList = DataVar.toJSONList();
LocationList = list();
for each  Locationdata in DataList
{
  LocationList.add(Locationdata.getJson("Location"));
}
for each  Location in LocationList
{
  Name = Location.getJSON("Name");
  Desi = Location.getJSON("Id");
  insert into contact_table
  [
      LocationName=Name
      Location_ID=Desi
      Added_User=zoho.loginuser
  ]
}
DataList = DataVar.toJSONList();
custList = list();
for each  custdata in DataList
{
  custList.add(custdata.getJson("Customer"));
}
info custList;
for each  Customer in custList
{
Name = Customer.getJSON("Name");
Desi = Customer.getJSON("Id");
insert into contact_table
[
  CustomerName=Name
  CustomerId=Desi
]
} ```