ColdFusion serializeJSON添加//字符

时间:2016-09-01 11:17:28

标签: json coldfusion youtube-api

我已经编写了一些代码来与YouTube API进行交互,在开发方面它运行良好 - 接受它没有!

我发现serializeJSON的输出正在添加//

        <cfset jsonUpdateVideo={
        "id"= "#arguments.videoId#",            
         "snippet"= {
         "title"= "#arguments.title#",
         "description"= "#arguments.description#",
         "tags"= [#trim(lstTags)#],
         "categoryId"= "28"
        },
          "status"= {
          "privacyStatus"= "#arguments.privacy#",
          "embeddable"= True,
          "license"= "youtube"
          }
    }>

的结果
  

serializeJSON(jsonUpdateVideo)

//{"status":{"embeddable":true,"privacyStatus":"Private","license":"youtube"},"snippet":{"description":"More information about this video can be found at some URL","categoryId":28,"title":"Video Test","tags":["\"tag1\", \"tag2\", \"tag3\", \"tag4\", \"tag4\", \"tag5\""]},"id":"_jI4GfjnGCM"} 

如果我将其粘贴到YouTube API资源管理器中,而不是//它可以正常工作并更新视频详细信息。

不知道//来自哪里,因为它在开发上没问题。

1 个答案:

答案 0 :(得分:2)

在ColdFusion管理中,有一个选项。

使用前缀序列化JSON //

通过在序列化的JSON字符串前加上自定义前缀,保护从跨站点脚本攻击中返回JSON数据的Web服务。

这是在一个环境而不是另一个环境中启用的,现在我可以在两个环境中启用它 - 我想我会手动删除它。

现在我知道要搜索什么,我找到更多答案...... Coldfusion 10 returnformat="JSON" adding characters