Skip to content

Instantly share code, notes, and snippets.

@vikaskanani
Created May 28, 2019 04:25
Show Gist options
  • Save vikaskanani/8dd175709e8f997b5cfd4a29bc0f0b1c to your computer and use it in GitHub Desktop.
Save vikaskanani/8dd175709e8f997b5cfd4a29bc0f0b1c to your computer and use it in GitHub Desktop.
Prepare list for photo services
<cfset contractorArray = ["Vikas", "Bharat", "Pritesh", "Ashish"] />
<cfset serviceArray = ["Lawncare", "Snow removal", "Winterization", "Occupancy Check"] />
<cfset jobArray = [
{ "jobNo": "J8235-62", "contractor": "Vikas", "services": ["Lawncare", "Snow removal"] },
{ "jobNo": "J8235-63", "contractor": "Bharat", "services": ["Snow removal", "Winterization"] },
{ "jobNo": "J8235-64", "contractor": "Bharat", "services": ["Lawncare", "Snow removal", "Winterization"] },
{ "jobNo": "J8235-65", "contractor": "Pritesh", "services": ["Winterization", "Occupancy Check"] },
{ "jobNo": "J8235-66", "contractor": "Vikas", "services": ["Snow removal"] },
{ "jobNo": "J8235-67", "contractor": "Pritesh", "services": ["Snow removal"] },
{ "jobNo": "J8235-68", "contractor": "Vikas", "services": ["Lawncare", "Occupancy Check"] },
{ "jobNo": "J8235-69", "contractor": "Ashish", "services": ["Lawncare"] },
{ "jobNo": "J8235-70", "contractor": "Pritesh", "services": ["Occupancy Check"] },
{ "jobNo": "J8235-71", "contractor": "Pritesh", "services": ["Lawncare", "Snow removal", "Winterization", "Occupancy Check"] },
] />
<cfset photoArray = [] />
<cfloop array="#jobArray#" item="obj">
<cfloop array="#obj.services#" item="service">
<cfset photoArray.append({
"jobNo": obj.jobNo,
"contractor": obj.contractor,
"service": service
}) />
</cfloop>
</cfloop>
<cfoutput>#serializeJSON(photoArray)#</cfoutput>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment