4 kyu

Objectify a URL Query String

2,892 of 2,904OverZealous

Description:

In this kata, we want to convert a URL query string into a nested object. The query string will contain parameters that may or may not have embedded dots ('.'), and these dots will be used to break up the properties into the nested object.

You will receive a string input that looks something like this:

user.name.firstname=Bob&user.name.lastname=Smith&user.favoritecolor=Light%20Blue

Your method should return an object hash-map that looks like this:

{
  'user': {
    'name': {
      'firstname': 'Bob',
      'lastname': 'Smith'
    },
    'favoritecolor': 'Light Blue'
  }
}
  • You can expect valid input. You won't see input like:
    // This will NOT happen
    foo=1&foo.bar=2
    
  • All properties and values will be strings — and the values should be left as strings to pass the tests.
  • Make sure you decode the URI components correctly
Algorithms

Stats:

CreatedNov 16, 2013
PublishedNov 16, 2013
Warriors Trained7951
Total Skips1822
Total Code Submissions29682
Total Times Completed2904
JavaScript Completions2892
Total Stars314
% of votes with a positive feedback rating93% of 368
Total "Very Satisfied" Votes324
Total "Somewhat Satisfied" Votes40
Total "Not Satisfied" Votes4
Ad
Contributors
  • OverZealous Avatar
  • jhoffner Avatar
  • Voile Avatar
Ad