Skip to content

Instantly share code, notes, and snippets.

View sahanDissanayake's full-sized avatar

Sahan Dissa sahanDissanayake

View GitHub Profile
@sahanDissanayake
sahanDissanayake / flatenArray.js
Created September 7, 2016 07:40
Turn a nested array in to a single array of components
// [[1,2,[3]],4] -> [1,2,3,4]
var unflattenedArray = [[1,2,[3]],4],
flattenedArray = [];
flattenedArray = unflattenedArray.toString().split(',').map(function(arrayItem) {
return parseInt(arrayItem);
});
// https://gist.github.com/brucekirkpatrick/7026682
/**
* $.unserialize
*
* Takes a string in format "param1=value1&param2=value2" and returns an object { param1: 'value1', param2: 'value2' }. If the "param1" ends with "[]" the param is treated as an array.
*
* Example:
*
* Input: param1=value1&param2=value2
* Return: { param1 : value1, param2: value2 }
{
"meta": {
"code": 200
},
"notifications": [
{
"type": "notificationTray",
"item": {
"unreadCount": 0
}