Normalize nested params in JavaScript