Skip to content

Instantly share code, notes, and snippets.

@MaryamZi
Created September 25, 2019 16:42
Show Gist options
  • Save MaryamZi/6a9eb2446757c62c0b7933b4b89deb4a to your computer and use it in GitHub Desktop.
Save MaryamZi/6a9eb2446757c62c0b7933b4b89deb4a to your computer and use it in GitHub Desktop.
function convertToJsonObjectArray(string[][] records) returns map<json>[] {
// Remove and ignore the first element which represents the columns.
_ = records.shift();
map<json>[] objectArray = records.map(function(string[] currentRecord) returns map<json> {
map<json> obj = {
id: checkpanic 'int:fromString(currentRecord[0]),
firstName: currentRecord[1],
lastName: currentRecord[2],
age: checkpanic 'int:fromString(currentRecord[3])
};
return obj;
});
return objectArray;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment