user3636388 :
How do we convert the following parameter string to JSON using node.
"token=1234&team_id=TADAS&team_domain=testddomain&channel_id=AVC"
The expected output is
{ "token":1234, "team_id":"TADAS","team_domain":"testddomain","channel_id":"AVC"}
Tried JSON.parse, not working - Uncaught SyntaxError: Unexpected token o in JSON at position 1
Mohit Prakash :
You can use querystring library of node js
var qs = require("querystring")
var json = qs.parse("token=1234&team_id=TADAS&team_domain=testddomain&channel_id=AVC")
then the output is like this
{ "token":1234, "team_id":"TADAS","team_domain":"testddomain","channel_id":"AVC"}
You can refer this link https://nodejs.org/api/querystring.html#querystring_querystring_parse_str_sep_eq_options
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=220236&siteId=1