cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamically flatten json to csv from Salesforce?

bill_sturdivant
New Contributor III

I need to be able to read any object in Salesforce and write it out as a CSV file. To do this I need to be able to flatten the output dynamically.

Sample json:

[{
		"Account_Class_vod__c" : "abc",
		"ShippingAddress" : {
			"city" : "aaa",
			"country" : "Russia",
			"countryCode" : null,
			"geocodeAccuracy" : null,
			"latitude" : null,
			"longitude" : null,
			"postalCode" : "306200",
			"state" : "sss",
			"stateCode" : null,
			"street" : "st"
		},
		"Ownership" : "N"
	}, {
		"Account_Class_vod__c" : "abc",
		"ShippingAddress" : {
			"city" : "aaa",
			"country" : "Russia",
			"countryCode" : null,
			"geocodeAccuracy" : null,
			"latitude" : null,
			"longitude" : null,
			"postalCode" : "306200",
			"state" : "sss",
			"stateCode" : null,
			"street" : "st"
		},
		"Ownership" : "N"
	}, {
		"Account_Class_vod__c" : "abc",
		"ShippingAddress" : {
			"city" : "aaa",
			"country" : "Russia",
			"countryCode" : null,
			"geocodeAccuracy" : null,
			"latitude" : null,
			"longitude" : null,
			"postalCode" : "306200",
			"state" : "sss",
			"stateCode" : null,
			"street" : "st"
		},
		"Ownership" : "N"
	}
]
1 ACCEPTED SOLUTION

aleung
Contributor III

We solve this by using a python script. I shared this under “Showcase” section. You can locate the “flattener” python script under Utilties / Collection of Python Scripts.

View solution in original post

8 REPLIES 8

aleung
Contributor III

We solve this by using a python script. I shared this under “Showcase” section. You can locate the “flattener” python script under Utilties / Collection of Python Scripts.

Exactly what I was looking for! Thanks!

I cant find this script. Can you please guide me to correct location for this script.

Surya, if you check out the post here, Alan links to a box folder with the resource you are looking for.