Skip to content

Instantly share code, notes, and snippets.

@kannan4k
Created August 5, 2015 04:45
Show Gist options
  • Save kannan4k/99ae3363ed0755411fde to your computer and use it in GitHub Desktop.
Save kannan4k/99ae3363ed0755411fde to your computer and use it in GitHub Desktop.
if data['supplemental_data']
data['supplemental_data'].inject({}) do |sum, parts|
sum
key, value = parts
sum[key.to_sym] = value.values
sum
end
else
{}
end
#Here is the 'data' json which is converted into hash
#"supplemental_data": {
# "groups": {
# "144959": {
# "id": 144959,
# "name": "test3",
# "last_modified": "2013-07-12T15:32:25+00:00",
# "created": "2013-07-12T15:32:25+00:00"
# }
# }
# }
@kannan4k
Copy link
Author

kannan4k commented Aug 5, 2015

"supplemental_data": {
  "users": {
   "1242515": {
    "id": 1242515,
    "first_name": "Alexander",
    "last_name": "Luzzana",
    "group_id": 144959,
    "active": true,
    "employee_number": 4,
    "salaried": true,
    "exempt": false,
    "username": "aluzzana",
    "email": "garrett@tsheets.com",
    "payroll_id": "4",
    "hire_date": "2012-07-01",
    "term_date": "0000-00-00",
    "job_title": "",
    "gender": "",
    "last_modified": "2013-07-12T15:52:00+00:00",
    "last_active": "2013-07-01T22:51:28+00:00",
    "created": "2013-05-28T20:23:44+00:00",
    "mobile_number": ""
   }
  },
  "jobcodes": {
   "17285791": {
    "id": 17285791,
    "parent_id": 0,
    "assigned_to_all": true,
    "billable": false,
    "active": true,
    "type": "pto",
    "has_children": false,
    "billable_rate": 0,
    "short_code": "",
    "name": "Sick",
    "last_modified": "2013-05-28T17:49:24+00:00",
    "created": "2013-05-28T17:49:24+00:00"
   },
   "17285793": {
    "id": 17285793,
    "parent_id": 0,
    "assigned_to_all": true,
    "billable": false,
    "active": true,
    "type": "pto",
    "has_children": false,
    "billable_rate": 0,
    "short_code": "",
    "name": "Vacation",
    "last_modified": "2013-05-28T17:49:24+00:00",
    "created": "2013-05-28T17:49:24+00:00"
   },
   "17285795": {
    "id": 17285795,
    "parent_id": 0,
    "assigned_to_all": true,
    "billable": false,
    "active": true,
    "type": "pto",
    "has_children": false,
    "billable_rate": 0,
    "short_code": "",
    "name": "Holiday",
    "last_modified": "2013-05-28T17:49:24+00:00",
    "created": "2013-05-28T17:49:24+00:00"
   },
   "17288283": {
    "id": 17288283,
    "parent_id": 0,
    "assigned_to_all": false,
    "billable": false,
    "active": true,
    "type": "regular",
    "has_children": false,
    "billable_rate": 0,
    "short_code": "dev",
    "name": "Development Team",
    "last_modified": "2013-05-28T20:19:33+00:00",
    "created": "2013-05-28T20:19:33+00:00"
   }
  }
 }
}```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment