Parse Query String (Typed)

JavaScript Hard 3 views
Back to Questions

Problem Description

You get a query string like key=value&key=value. Decode %xx and + as space. Convert values: 'true'/'false' -> boolean, numbers -> number, else string. Repeated keys become arrays. Print JSON object.

Input Format

One line query string.

Output Format

One line JSON object.

Sample Test Case

Input:
a=1&b=true&c=hi+bro&b=2
Output:
{"a":1,"b":[true,2],"c":"hi bro"}

Constraints

Length up to 2e5.

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next