Skip to content

Instantly share code, notes, and snippets.

@toanshulverma
Created April 4, 2023 18:45
Show Gist options
  • Save toanshulverma/663edcefdf2f7699e947a5d97b45ba81 to your computer and use it in GitHub Desktop.
Save toanshulverma/663edcefdf2f7699e947a5d97b45ba81 to your computer and use it in GitHub Desktop.
Convert Salesforce platform event JSON to CSV
# Insert record with attachment
# Usage: ./convertPEJsonToCSV.ps1 -inputFile "./eventjson.json" -output "./uat_event.csv"
param (
[string]$inputFile,
[string]$outputFile
)
# create record
echo "input = $inputFile"
$objectData = Get-Content -Raw "$inputFile" | ConvertFrom-Json
$records = @()
foreach ($obj in $objectData){
$records += $obj.data.payload
#echo "payload = " $obj.data.payload
}
$records | Export-Csv -Path $outputFile -NoTypeInformation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment