js中字符串转json对象时报错: Uncaught SyntaxError: Unexpected token s in JSON at position 2
解决方法:
js中获取jsp的返回值
var json='${channels}'
var channels = JSON.parse(json);就报上面的错。
json的值最终会转成这种json格式: '[{sc_it_id=, sc_server_port=7890}]',但使用parse这个方法,要求很严格,必须var str1 = '{ "sc_it_id":"","sc_server_port":"7890" }';就是json的k和value必须都用双引号包起来;
原文地址:http://www.yayihouse.com/yayishuwu/chapter/1331
js中字符串转json对象时报错: Uncaught SyntaxError: Unexpected token s in JSON at position 2的更多相关文章
- 关于Uncaught SyntaxError: Unexpected token o in JSON at position 1,chrome持续报错的相关解析
今天跟大家分享我前两天遇见的一个BUG,说出来很难受,因为这个BUG花了我一个多小时去找原因,后来莫名其妙的故障消失了,强迫症犯了的我,居然花了2个多小时去故意再制造这个BUG,只想弄明白WHY??? ...
- VM603:1 Uncaught SyntaxError: Unexpected token o in JSON at position 1
再用JQuery解析json的时候出现了这样一个问题 VM603: Uncaught SyntaxError: Unexpected token o 通过查阅资料发现,是由于解析json文件的时候解析 ...
- jquery使用ajax报错[Uncaught SyntaxError: Unexpected token :]
$.post('/ajax/validate.do',{"id": id},function(ret){ //ret }); 返回值明明是json,格式也是正确的,却解析不成功,在 ...
- vue - public 引入 <script>报错 Uncaught SyntaxError: Unexpected token '<'
1.现象 原本我是直接在母版引入 <script type="application/javascript" src="static/config.js" ...
- 打开了chrome审查元素 发现报错 Uncaught SyntaxError: Unexpected token )
这个错误并不影响业务处理,但是看到有报错,心里总是不爽. 经过几番查找,发现了原因. <a href="javascript:void()" oncick="onS ...
- vue项目npm run dev 报错Uncaught SyntaxError: Unexpected token <
目前代码所处位置是micro分支,该分支是从dev分支直接拉下来进行npm run dev的,而dev分支是可以正常运行的,网上的诸多解释是babel转义时候报错,其实对比可见,两个分支不同的地方应该 ...
- Thinkphp中js报错,Uncaught SyntaxError: Unexpected token }
tp中js在行末使用注释报错Uncaught SyntaxError: Unexpected token } if (new_directors==1) {// 注释 解决办法:注释换成单行 if ( ...
- JSON.parse()——Uncaught SyntaxError: Unexpected token \ in JSON at position 1
背景:项目安全处理方面之一 ——对特殊字符进行编解码(后端编码,前端解码) 特殊字符: " %22 \ %5C / %2F & %26 % %25 ' ...
- js Uncaught SyntaxError: Unexpected token错误
今天遇到js报错Uncaught SyntaxError: Unexpected token 不知道是什么原因,并且js还会继续往下执行. 经过排查竟然是在保存行的上面有个if少一个大括号,真是坑爹啊 ...
随机推荐
- AcWing 846. 树的重心
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> ...
- springboot整合mybatis连接oracle
pom.xml: <!-- 链接:https://pan.baidu.com/s/1agHs5vWeXf90r3OEeVGniw 提取码:wsgm --> <dependency&g ...
- centos7的netca命令和netmgr命令、dbca命令等基础知识点
netca命令: netmgr命令: dbca命令: database assistant configuration 中的SGA 和PGA SGA:System Global Area是Oracl ...
- Postman如何测试Webservice接口?
一般情况下使用soapui工具测试ws接口,那么能不能使用postman测试呢?当然可以,往下看. 1. 首先请求类型为post 填写上ws地址 ,url地址后不追加?wsdl 2. 设置请求头 he ...
- Django框架之ORM的相关操作之分页(六)
分页是每个项目必不可少要写的一个功能,该篇文章就将记录一下使用ORM写分页的过程. 假设我们的数据库里面需要显示一些数据,而这个表中的数据大约有几千条数据,那么我们不可能将所有的数据都显示出来,那么就 ...
- 吴裕雄 PYTHON 人工智能——基于MASK_RCNN目标检测(5)
import os import sys import numpy as np import tensorflow as tf import matplotlib import matplotlib. ...
- 11: Django + gunicorn + Nginx 的生产环境部署
1.1 gunicorn介绍 1.Gunicorn 1. Gunicorn是使用Python实现的WSGI服务器, 直接提供了http服务, 并且在woker上提供了多种选择, gevent, e ...
- java 实现一段文字中,出现次数最多的字
代码如下: public static void main(String[] args) { String str = "大批量,之前都没怎么注意过,这个问题确实不会,网上参考了下别人的,大 ...
- Draw.io--自认为最好用的流程图绘制软件
draw.io 是一个强大简洁的在线的绘图网站,支持流程图,UML图,架构图,原型图等图标.支持Github,Google Drive, One drive等网盘同步,并且永久免费.如果觉得使用Web ...
- C++中使用sstream进行类型转换(数字字符串转数字、数字转数字字符串)
1.sstream知识 sstream即字符串流.在使用字符串流sstream时,需要先引入相应的头文件 "#include <sstream>" 基本操作 // 引入 ...