Skip to content

Instantly share code, notes, and snippets.

@BransonGitomeh
Created September 8, 2017 20:12
Show Gist options
  • Save BransonGitomeh/c8fa9997efd8f271cd9a7bb0574eedcd to your computer and use it in GitHub Desktop.
Save BransonGitomeh/c8fa9997efd8f271cd9a7bb0574eedcd to your computer and use it in GitHub Desktop.
const test = { Item:[ { Name: 'Amount', Value: 5 },{ Name: 'MpesaReceiptNumber', Value: 'LI85581A6Z' },{ Name: 'Balance' }, {Name: 'TransactionDate', Value: '20170908181744' }, { Name: 'PhoneNumber', Value: '254723587767' } ] }
const corrected = {}
test.Item.map(node=>corrected[node.Name] = node.Value)
console.log(corrected)
// { Amount: 5,
// MpesaReceiptNumber: 'LI85581A6Z',
// Balance: undefined,
// TransactionDate: '20170908181744',
// PhoneNumber: '254723587767' }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment