【问题标题】:Parse JSONObject [duplicate]解析 JSONObject [重复]
【发布时间】:2014-11-22 14:19:16
【问题描述】:

我有以下 JSONObject:

{"Questions":
        "{Question5=[Answer1, Answer2, Answer3, Answer4], Question4=[Answer1, Answer2, Answer3, Answer4], Question3=[Answer1, Answer2, Answer3, Answer4], Question2=[Answer1, Answer2, Answer3, Answer4], Question1=[Answer1, Answer2, Answer3, Answer4]}"
}

我对使用 JSON 非常陌生。我需要的是 JSON 对象数组,每个键是 Question5、Question4 等,而值是答案。你能帮忙吗?

【问题讨论】:

  • 你看过JacksonGSON吗?
  • 去 json.org 学习 JSON 语法。学习只需5-10分钟。但请注意,如果您转储 Maps & Lists,或某些 JSON API 使用的 Map/List 等效对象,它们可能不会像 JSON 源一样显示(在 println 中通过 toString())。
  • 但看起来你的“问题”字符串确实只是一个字符串,而不是 JSON。

标签: java json parsing


【解决方案1】:

你需要解析它。我建议 GSON 图书馆这样做。 但正如我所见,您的字符串不是 JSON。 json 应该是 key : value 而不是 key=value 作为你的字符串

【讨论】:

  • 我用 JSONObject(map) 创建它
猜你喜欢
  • 2015-07-05
  • 1970-01-01
  • 2013-11-13
  • 1970-01-01
  • 2016-08-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多