Skip to content

Instantly share code, notes, and snippets.

@antonybudianto
Last active February 8, 2017 15:50
Show Gist options
  • Save antonybudianto/959c3446328e5c8266ce078646dac7b1 to your computer and use it in GitHub Desktop.
Save antonybudianto/959c3446328e5c8266ce078646dac7b1 to your computer and use it in GitHub Desktop.
function jsonToFirebaseJSON(arr) {
const result = arr.reduce((acummulator, current, index) =>
(Object.assign({}, acummulator, {[index]: current})), {});
return JSON.stringify(result);
}
// index can be replaced with your id/primary key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment