Created
April 4, 2023 18:45
-
-
Save toanshulverma/663edcefdf2f7699e947a5d97b45ba81 to your computer and use it in GitHub Desktop.
Convert Salesforce platform event JSON to CSV
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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