从JSON输出中删除方括号

时间:2016-07-30 00:21:11

标签: java json

大家好我想从json输出中删除方括号。

[
  {
    "author": "Mark Twain",
    "book": "The Adventures of Tom Sawyer",
    "cost": "$68",
    "id": "1"
  },
  {
    "author": "Arthur Conan Doyle",
    "book": "The Adventures of Sherlock Holmes",
    "cost": "$97",
    "id": "2"
  }
]

我使用下面的一个删除括号,如果我是正确的话得到输出

List<Book> list = new ArrayList<Book>();
list=(List<Book>)JSONArray.toList(
    JSONArray.fromObject(books.values()),
    new Object(),
    new JsonConfig()
);
return list;

添加了所需的罐子。但是我收到错误(控制台输出)

WARNING: Tried to assign property author:java.lang.String to bean of class java.lang.Object
Jul 29, 2016 5:16:45 PM net.sf.json.JSONObject toBean

WARNING: Tried to assign property book:java.lang.String to bean of class java.lang.Object
Jul 29, 2016 5:16:45 PM net.sf.json.JSONObject toBean

WARNING: Tried to assign property cost:java.lang.String to bean of class java.lang.Object
Jul 29, 2016 5:16:45 PM net.sf.json.JSONObject toBean

WARNING: Tried to assign property id:java.lang.String to bean of class java.lang.Object
Jul 29, 2016 5:16:45 PM net.sf.json.JSONObject toBean

WARNING: Tried to assign property author:java.lang.String to bean of class java.lang.Object
Jul 29, 2016 5:16:45 PM net.sf.json.JSONObject toBean

WARNING: Tried to assign property book:java.lang.String to bean of class java.lang.Object
Jul 29, 2016 5:16:45 PM net.sf.json.JSONObject toBean

WARNING: Tried to assign property cost:java.lang.String to bean of class java.lang.Object
Jul 29, 2016 5:16:45 PM net.sf.json.JSONObject toBean

WARNING: Tried to assign property id:java.lang.String to bean of class java.lang.Object

我的邮递员给了我一个500内部服务器错误

任何帮助表示赞赏 谢谢

0 个答案:

没有答案