How can I replace values matching a certain key in a JSON wrap in a QueryString?

Shamoon :

I have:

queryString=`key_value="something"&type_name=user&value={"password":"Test1234"}&key_attribute=guid`

I want to replace the password of Test1234 with [HIDDEN].

Jew :

If you are in node, you can just parse and then stringify the query string

var qs=require("querystring")
var temp=qs.parse(queryString)
var user=JSON.parse(temp.value)
user.password='[HIDDEN]'
temp.value=JSON.stringify(user)
queryString=qs.stringify(temp)

Browserify have also a querystring implementation, but you also want to use regexp

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=220676&siteId=1