Home > Net >  Logic Apps :: parse JSON or CSV and make a list of e-mails separated by semi column
Logic Apps :: parse JSON or CSV and make a list of e-mails separated by semi column

Time:12-27

I created a enter image description here

So the question is how to:

  1. parse JSON or CSV file
  2. take each value only one and erase NULLs
  3. separate each value by a column or semi column
  4. insert that into the e-mail recipient in Logic App.

CodePudding user response:

After reproducing from my end, I could able to get this work by Parsing the json initially. Considering below is the Json, I have used Parse JSON action in order to extract tags_createdBy column.

[
  {
    "location": "westeurope",
    "name": "Resource",
    "tags_createdBy": "[email protected]",
    "type": "microsoft.compute/virtualmachines"
  },
  {
    "location": "eastus",
    "name": "Resource",
    "tags_createdBy": "[email protected]",
    "type": "microsoft.compute/virtualmachines"
  },
  {
    "location": "eastus",
    "name": "Resource",
    "tags_createdBy": "[email protected]",
    "type": "microsoft.compute/virtualmachines"
  },
  {
    "location": "eastus",
    "name": "Resource",
    "tags_createdBy": "[email protected]",
    "type": "microsoft.compute/virtualmachines"
  },
  {
    "location": "eastus",
    "name": "Resource",
    "tags_createdBy": "[email protected]",
    "type": "microsoft.compute/virtualmachines"
  },
  {
    "location": "westeurope",
    "name": "Resource",
    "tags_createdBy": "[email protected]",
    "type": "microsoft.compute/virtualmachines"
  },
  {
    "location": "eastus",
    "name": "Resource",
    "tags_createdBy": "[email protected]",
    "type": "microsoft.compute/virtualmachines"
  },
  {
    "location": "eastus",
    "name": "Resource",
    "tags_createdBy": "[email protected]",
    "type": "microsoft.compute/virtualmachines"
  },
  {
    "location": "eastus",
    "name": "Resource",
    "tags_createdBy": "[email protected]",
    "type": "microsoft.compute/virtualmachines"
  },
  {
    "location": "germanywestcentral",
    "name": "Resource",
    "tags_createdBy": "[email protected]",
    "type": "microsoft.compute/virtualmachines"
  },
  {
    "location": "westeurope",
    "name": "Resource",
    "tags_createdBy": "[email protected]",
    "type": "microsoft.compute/virtualmachines"
  },
  {
    "location": "switzerlandnorth",
    "name": "Resource",
    "tags_createdBy": "[email protected]",
    "type": "microsoft.compute/virtualmachines"
  },
  {
    "location": "eastus",
    "name": "Resource",
    "tags_createdBy": "",
    "type": "microsoft.sql/servers/databases"
  },
  {
    "location": "westeurope",
    "name": "Resource",
    "tags_createdBy": "",
    "type": "microsoft.storage/storageaccounts"
  },
  {
    "location": "switzerlandnorth",
    "name": "Resource",
    "tags_createdBy": "[email protected]",
    "type": "microsoft.storage/storageaccounts"
  },
  {
    "location": "eastus",
    "name": "Resource",
    "tags_createdBy": "[email protected]",
    "type": "microsoft.storage/storageaccounts"
  },
  {
    "location": "germanywestcentral",
    "name": "Resource",
    "tags_createdBy": "[email protected]",
    "type": "microsoft.storage/storageaccounts"
  },
  {
    "location": "germanywestcentral",
    "name": "Resource",
    "tags_createdBy": "[email protected]",
    "type": "microsoft.storage/storageaccounts"
  },
  {
    "location": "eastus",
    "name": "Resource",
    "tags_createdBy": "",
    "type": "microsoft.storage/storageaccounts"
  },
  {
    "location": "eastus",
    "name": "Resource",
    "tags_createdBy": "",
    "type": "microsoft.storage/storageaccounts"
  },
  {
    "location": "eastus",
    "name": "Resource",
    "tags_createdBy": "[email protected]",
    "type": "microsoft.storage/storageaccounts"
  },
  {
    "location": "eastus",
    "name": "Resource",
    "tags_createdBy": "",
    "type": "microsoft.storage/storageaccounts"
  },
  {
    "location": "westeurope",
    "name": "Resource",
    "tags_createdBy": "",
    "type": "microsoft.storage/storageaccounts"
  }
]

Here is the flow of my logic app which extracts tags_createdBy from the json and saves it in an array variable using Append to array variable.

enter image description here

To remove duplicates and get only the unique values, I have used union and filtered the array to remove null values from the resultant. Below is the expression and the flow used in my logic app.

union(variables('tags_createdBy'),variables('tags_createdBy'))

Expression to replace ',' with ';'

replace(string(body('Filter_array')),',',';')

enter image description here

RESULTS:

enter image description here

enter image description here

  • Related