gpt4 book ai didi

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

转载 作者:IT老高 更新时间:2023-10-28 12:47:48 29 4
gpt4 key购买 nike

我正在尝试使用 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 }'

关于json - 使用 HTTPie 发送嵌套的 JSON 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37215565/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com