javascript - Convert special HTML character codes like " to normal characters -
i have code in .cshtml file outputs json string:
window.teagent = { id: @user.agentid , roles: '@user.roles' }
but how looks when view page source or call window.teagent
javascript:
window.teagent = { id: 47650 , roles: '{"rolesforuser":["agent","wvs"]}' }
how can convert each "
"
looks this?
{"rolesforuser":["agent", "wvs"]}
use html.raw
prevent string being html encoded:
window.teagent = { id: @user.agentid, roles: @html.raw(user.roles) }
Comments
Post a Comment