我有一个解析的JSON,看起来像这样
{
"pageName":"dsfdsf:sdfdsf:home",
"prop1":"dsf:dsf","prop46":"OD",
"prop5":"/content/",
"prop24":"A Taste Of Home",
"prop6":"1c4074ca-89bf-4d9f-8bd2-a5dc5f3ecf74",
"prop3":"Home",
"prop70":"dsf",
"prop4":"dsf",
"prop71":"desktop",
"prop10":["dsfdsf"],
"prop11":["sdfdsf"],
"channel":"dsf"
}
我可以从中提取密钥和值。我想在我的脚本标记中将此映射设置为JS变量,如
<script type="text/javascript">
s.channel ="dsf" // i need the prefix to be s. always and the variable should be set as s.key=value;
</script>
当我做s.key=value
时没有任何反应。我已经尝试将s
定义为JS
对象,但没有快乐。我想将这些值传递给Tracking服务器,因此变量名称必须为s
。
以下作品
if(key==="channel"){
s.channel = value // this works
但s.key=value
没有。