`

Json解析异常Value of type java.lang.String cannot be converted to JSONObject

 
阅读更多

今天解析json遇到 org.json.JSONException: Value of type java.lang.String cannot be converted to JSONArray

在4.0版本没有问题,但在2.3.7版本就遇到这问题很奇怪,我的josn是用ultraEdit文本编辑器保存为UTF-8的,但还是报这错误,后来查到了:

 

 该异常有 json 文件编码所引起的,所以切切不要应用 记事本 编辑 json 文件,而应选择其他文本编辑器,如 EditPlus ,并重视保存编码格局为 UTF-8,不然可能产生中文乱码。

 

 用记事本编辑后,即使 另存为 UTF-8 情势,也会产生乱码,因为保存在为 UTF-8 + BOM 编码

 

 

后来用EditPlus保存为UTF-8就没有问题了

分享到:
评论

相关推荐

    java实现排序算法

    Java作为广泛应用的编程语言,提供了一种高效的方式来实现各种排序算法。本文将深入探讨七种常见的排序算法及其在Java中的实现。 1. 冒泡排序(Bubble Sort) 冒泡排序是一种简单的排序算法,它重复地遍历待排序的...

    java完美按格式化字符串String转sql.date

    ### Java完美按格式化字符串String转sql.Date 在Java编程中,经常需要处理日期与时间相关的数据。特别是在数据库操作时,经常会遇到需要将字符串类型的日期转换为`java.sql.Date`类型的情况。本文将详细介绍如何...

    json.js_json2.js

    // be converted to Date objects. myData = JSON.parse(text, function (key, value) { var a; if (typeof value === 'string') { a = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec...

    JSP Simple Examples

    and one of the feature of OOP in java is that, we can assign a subclass object or variable to the variable of the superclass type. Log files Log files keeps a records of internet protocol addresses...

    数据库工具类DatabaseUtil.java

    java.lang.reflect.Method method = clazz.getMethod("close", null); method.invoke(resource, null); } catch (Exception e) { // e.printStackTrace(); } } /** * 执行 SELECT 等 SQL 语句并返回结果集. ...

    C# to Java 代码转换工具

    Folder conversion: Entire folders of C# code files are converted to Java code files.(文件夹转换) 2. Code snippet and file conversion: Our snippet conversion accuracy is outstanding and does not ...

    将长整型转换为字符串的Java程序.docx

    输出转换后的类型:java.lang.String 999999999999 总结: 在 Java 中,有多种方式可以将长整型(Long)转换为字符串: A. 使用 + 运算符: 这是最简单的方法,只需将 Long 变量与空字符串 "+" 相加,即可完成...

    linqer_4.6.0.0_trial.exe

    Not every SQL statement can be converted to LINQ, but Linqer covers many different types of SQL expressions. Linqer supports both .NET languages - C# and Visual Basic. Because LINQ is a part of the ...

    TypeError: only integer tensors of a single element can be converted to an index

    在调整loss计算的时候遇到了TypeError: only integer tensors of a single element can be converted to an index这个问题,原来的计算公式为: self.loss_D = (self.loss_D_fake + self.loss_D_real) * 0.5 调整后...

    A tiny JSON library for C++11.

    There are also implicit constructors that allow standard and user-defined types to be automatically converted to JSON. For example: class Point { public: int x; int y; Point (int x, int y) : x(x),...

    DWR,web.xml,dwr.xml,converted,created

    DWR初学者专题,有详细笔记。 DWR很轻松就学会。 取得dwr的dwr.jar包和其他dwr所需的其他jar包 web.xml ...如果远程Bean A有个方法A.blah(B),那么你需要为A建立一个created,为B建立一个converted.。。

    Android:Field can be converted to a local varible.的解决办法

    Android:Field can be converted to a local varible.的解决办法 前言: 使用 Android Studio 开发 Android 有一段时间了,偶尔会碰到 AS 在一些私有变量上有黄色高亮提示Field can be converted to a local ...

    Android代码-GetJSON

    It Gives data as a String which can be used to pass the data between activities which can then be converted to JsonObject to carry on further operations. It can also return data in JsonObject. It ...

    FlexGraphics_V_1.79_D4-XE10.2_Downloadly.ir

    - FIX: The value of some string flex-properties that began with a parenthese or curly bracket had no apostrophe at the end; that caused an error when reading. (fixed TPropList.SavePropValue for the ...

    CSharp 3.0 With the .NET Framework 3.5 Unleashed(english)

    - **Polymorphism**: Polymorphism allows objects of different classes to be treated as if they were of the same type, enabling flexibility and extensibility. ### 10. Coding Methods and Custom ...

    将内容中的符合url格式的字符串转换为超链接(JAVA版)

    在Java编程中,将文本内容中的符合URL格式的字符串转换为超链接是一项常见的需求,特别是在处理用户生成内容或网络爬虫应用中。本教程将详细讲解如何使用Java实现这一功能,主要涉及URL正则表达式匹配和字符串处理...

    Java程序将字符串转换为Long.docx

    System.out.println("The string '" + invalidStr + "' cannot be converted to a Long."); } ``` 此外,如果字符串可能包含非数字字符或者前导/尾随空格,那么在转换之前最好进行清理和验证,以避免异常。可以...

    Google C++ Style Guide(Google C++编程规范)高清PDF

    The definition of an inline function needs to be in a header file, so that the compiler has the definition available for inlining at the call sites. However, implementation code properly belongs in ....

    LuaUnicode icu-lua

    If you want to use the Unicode notion of string equality, or use Unicode strings as table keys, and you cannot guarantee that your strings are normalized, then you'll have to write or find a ...

Global site tag (gtag.js) - Google Analytics