Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
const serialize = uri => decodeURIComponent(uri).split('&').map(uri => ({ [uri.split('=')[0]]: uri.split('=')[1] })).reduce((a,b) => Object.assign(a,b))
console.log(serialize("_id%3D58c43d995cb9191a2f676b25%26index%3D0%26guid%3D798ebd68-22d5-4465-9d34-d4717891901d%26isActive%3Dfalse%26balance%3D%242%2C569.51%26picture%3Dhttp%3A%2F%2Fplacehold.it%2F32x32%26age%3D33%26eyeColor%3Dgreen%26name%3DDesiree%20Cervantes%26gender%3Dfemale%26company%3DSYNKGEN%26email%3Ddesireecervantes%40synkgen.com%26phone%3D%2B1%20(975)%20536-2019%26address%3D855%20Hendrickson%20Street%2C%20Libertytown%2C%20Marshall%20Islands%2C%205292%26about%3DElit%20anim%20occaecat%20proident%20consectetur%20veniam%20et%20deserunt%20irure.%20Sint%20aliquip%20fugiat%20aute%20tempor%20veniam%20eu%20duis%20mollit%20eiusmod%20aliquip%20ipsum%20enim%20do%20in.%20Pariatur%20nisi%20proident%20commodo%20duis%20nisi%20id%20ut%20commodo%20aute%20irure.%20Minim%20ut%20tempor%20in%20tempor%20dolor%20ex%20veniam%20fugiat.%20Sint%20cillum%20non%20qui%20elit%20amet%20deserunt%20ullamco.%20Commodo%20veniam%20reprehenderit%20est%20minim%20commodo%20qui%20ad%20occaecat%20nulla%20incididunt%20amet%20quis%20culpa.%20Fugiat%20consequat%20occaecat%20sint%20sunt%20et%20consequat%20anim.%26registered%3D2016-06-27T04%3A02%3A43%20-03%3A00%26latitude%3D-5.114506%26longitude%3D-67.527021%26greeting%3DHello%2C%20Desiree%20Cervantes!%20You%20have%204%20unread%20messages.%26favoriteFruit%3Dapple"))
// log
Object {
"_id": "58c43d995cb9191a2f676b25",
"about": "Elit anim occaecat proident consectetur veniam et deserunt irure. Sint aliquip fugiat aute tempor veniam eu duis mollit eiusmod aliquip ipsum enim do in. Pariatur nisi proident commodo duis nisi id ut commodo aute irure. Minim ut tempor in tempor dolor ex veniam fugiat. Sint cillum non qui elit amet deserunt ullamco. Commodo veniam reprehenderit est minim commodo qui ad occaecat nulla incididunt amet quis culpa. Fugiat consequat occaecat sint sunt et consequat anim.",
"address": "855 Hendrickson Street, Libertytown, Marshall Islands, 5292",
"age": "33",
"balance": "$2,569.51",
"company": "SYNKGEN",
"email": "desireecervantes@synkgen.com",
"eyeColor": "green",
"favoriteFruit": "apple",
"gender": "female",
"greeting": "Hello, Desiree Cervantes! You have 4 unread messages.",
"guid": "798ebd68-22d5-4465-9d34-d4717891901d",
"index": "0",
"isActive": "false",
"latitude": "-5.114506",
"longitude": "-67.527021",
"name": "Desiree Cervantes",
"phone": "+1 (975) 536-2019",
"picture": "http://placehold.it/32x32",
"registered": "2016-06-27T04:02:43 -03:00"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment