json 解析 A JSONArray text must start with '['
来源:互联网 发布:floyd算法流程图 编辑:程序博客网 时间:2024/05/19 20:59
json解析报错 A JSONArray text must start with '['
这里使用的是Android系统的,数据格式是正确的
JSONArray joa = new JSONArray(data);
解析代码就这一句 (数据格式是对,是对的,对的)问了好多人都说格式是不对,要是这问题怎么可能老去问了是吧
百度了好久也是什么格式问题啊 什么解析包导错了啦等等啊。。
昨天弄了一天 没有解决。谷歌了这样一条线索 可能数据编码影响,看返回的结果貌似是utf-8的,我又去看我下载数据的地方
public static String dealResponseResult(InputStream inputStream) {String resultData = null; // 存储处理结果ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();byte[] data = new byte[1024];int len = 0;try {while ((len = inputStream.read(data)) != -1) {byteArrayOutputStream.write(data, 0, len);}} catch (IOException e) {e.printStackTrace();}resultData = new String(byteArrayOutputStream.toByteArray());//System.out.println("结果"+resultData);return resultData;}
这里刻意没有转码,可还是不行。结果一位大神跟我说
可能传回来的数据带dom头,
把第一个字符取出来转成int应该是65279 应该是bom utf8的问题
也是我打印一个字符是空,并不是65279,不过截取第一个数据以后就可以了,反正就是编码问题
第一应该就是标识 去掉就可以解析了。
这个坑要记录下
0 0
- json 解析 A JSONArray text must start with '['
- Exception in thread "main" net.sf.json.JSONException: A JSONArray text must start with '[' at charac
- json解析异常org.json.JSONException: A JSONObject text must begin with '{' at character 1 of {的解决方法
- 关于json解析时异常org.json.JSONException: A JSONObject text must begin with '{' at character 1 of {的解决方法
- json解析时出现异常org.json.JSONException: A JSONObject text must begin with '{' at character 1 of {的解决方法
- httpclient domain must start with a dot
- urls must start with a leading slash
- The Contents.json describing the image set "BG_Email_Textfield.imageset" must start with a top level
- org.json.JSONException: A JSONObject text must begin with '{' at character 1 of {解决方法
- Java中json数据问题.报错 A JSONObject text must begin with '{'
- ValueError: urls must start with a leading slash
- 报错:The resource name must start with a letter
- TSLint: comment must start with a space (comment-format)
- The resource name must start with a letter
- JSONObject/JSONArray解析json
- json 解析jsonArray
- Data must start with zero
- JSON JSONArray 创建JSON 和 解析JSON
- Android30--Android之CoordinatorLayout布局的使用方式
- Notification和NotificationManager的基本使用方法
- 分页
- 实现iOS图片等资源文件的热更新化(二):自定义的动态 imageNamed
- Ubutun16.04好用的亮度调节工具
- json 解析 A JSONArray text must start with '['
- Adapter
- Apache common-lang 包
- SSOforJPush
- 初期草根站长适合做什么样的网站好?
- iOS 制作framework时,swift掉用OC,不支持桥接
- W5500 KEEPALIVE 功能流程简介以及应用
- [codeforces] 2A - Winner
- USB电池充电规范1.2版概述及充电检测器的重要角色