Created
September 25, 2019 16:42
-
-
Save MaryamZi/6a9eb2446757c62c0b7933b4b89deb4a to your computer and use it in GitHub Desktop.
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
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