Folks, using js libraries such as underscore
,underscore.string
, or lodash
, I'd like to convert the following String to an Object
'animals=cat&dogs&horses&fish=salmon&tuna';
The following are constant: animals
and fish
. Separator is =
The result should look like:
{
animals: 'cats&dogs&horses',
fish: 'salmon&tona'
}
animals
and fish
can occur in the string in any order.
Thanks!
PS Its not a duplicate of Parse query string in JavaScript... as the requirements are to return an object for later parsing...