I would like to send messages in the form of JSON objects to a server and parse the JSON response from the server.

Example of JSON object

{
  "post": {
    "username": "John Doe",
    "message": "test message",
    "image": "image url",
    "time":  "current time"
  }
}

我试图通过逐个属性手动解析JSON.是否有任何库/实用程序可用于简化此过程?

推荐答案

我很惊讶这些都没有被提及:而是使用json来代替简单的手工处理.org的小软件包GSon和Jackson使用起来更方便.所以:

So you can actually bind to your own POJOs, not some half-assed tree nodes or Lists and Maps. (and at least Jackson allows binding to such things too (perhaps GSON as well, not sure), JsonNode, Map, List, if you really want these instead of 'real' objects)

EDIT 19-MAR-2014:

Another new contender is Jackson jr library: it uses same fast Streaming parser/generator as Jackson (jackson-core), but data-binding part is tiny (50kB). Functionality is more limited (no annotations, just regular Java Beans), but performance-wise should be fast, and initialization (first-call) overhead very low as well. So it just might be good choice, especially for smaller apps.

Json相关问答推荐

SSIS Kingswaysoft Json源动态 node 名称

如何使用JQ有条件 Select 值

将PostgreSQL转换为JSON对象

合并2个嵌套词典

如何对未知/变量键的字典进行编码?

德纳比可视化区域图表 Power BI

如何使用Powershell查找所有包含特定键值对的JSON对象并迭代所有对象?

如何强制仅有一个元素的数组在JSON中生成方括号

匹配来自不同数组的值

使用 jolt 将对象数组转换为数组

try 使用 JQ 转换 JSON 中过于复杂的对象数组

从字节解码 JSON 数据,将 float 值更改为 int

将嵌套的 JSON 对象规范化为 Pandas 数据框

JBuilder中未定义的局部变量或方法json

JSON RPC - 什么是id?

如何在 json 编码字符串内的子数组数据周围添加方括号?

如何访问 JSON 对象数组的第一个元素?

使用适用于 Python 的 Google API - 我从哪里获取 client_secrets.json 文件?

MVC JsonResult camelCase 序列化

来自 Gson 的 JSON 字符串:删除双引号