I
I
Ivan Solovyov2018-04-03 16:25:17
JavaScript
Ivan Solovyov, 2018-04-03 16:25:17

How to convert data string to Json?

How can I convert this string to Json?

user_name=at&password=3

JSON.parse doesn't work.
I mean ready-made functions, it is clear that you can parse the symbols.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Eremin, 2018-04-03
@Ivan5130

Do you have url?

var url = new URL(urlString);
var user = url.searchParams.get("user_name");
var pass = url.searchParams.get("password");
var ob = {user_name:user, pass:password}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question