json - 使用 HTTPie 发送嵌套的 JSON 对象

我正在尝试使用 HTTPie 解析以发送一些嵌套的 JSON 对象,但我找不到如何。很清楚如何发送 JSON 对象而不是嵌套对象,例如

{ "user": { "name": "john" "age": 10 } }

最佳答案

2022 年 1 月发布的 HTTPie 3.0 更新:

现在使用 HTTPie 语言内置了对嵌套 JSON 的支持:

$ http pie.dev/post \
  tool[name]=HTTPie \
  tool[about][homepage]=httpie.io \
  tool[about][mission]='Make APIs simple and intuitive' \
  tool[platforms][]=terminal \
  tool[platforms][]=desktop \
  tool[platforms][]=web \
  tool[platforms][]=mobile 
{
    "tool": {
        "name": "HTTPie",
        "about": {
            "mission": "Make APIs simple and intuitive",
            "homepage": "httpie.io"
        },
        "platforms": [
            "terminal",
            "desktop",
            "web",
            "mobile"
        ]
    }
}

您可以在文档中了解有关嵌套 JSON 的更多信息:https://httpie.io/docs/cli/nested-json


HTTPie 3.0 之前的旧答案:

您可以pass the whole JSON via stdin :

$ echo '{ "user": { "name": "john", "age": 10 } }' | http httpbin.org/post

或specify the raw JSON as value with := :

$ http httpbin.org/post user:='{"name": "john", "age": 10 }'

https://stackoverflow.com/questions/37215565/

相关文章:

java - 在java中查询一个JSONObject

json - 可以引用 JSON 数字吗?

javascript - 在 Node.js 下存储 JSON 的简单方法

java - 仅使用字符串和值解析 JSON 对象

json - 服务器响应在中途被切断

json - 如何使用 Elasticsearch 搜索嵌套对象

c# - Web API 复杂参数属性全部为空

javascript - D3 - 如何处理 JSON 数据结构?

ruby-on-rails - rails : Render Json Status Problem

java - 如何使用 Jackson json 注释枚举字段以进行反序列化