blob: d2ea553b097cba0ab91fd6c548c57140bd065c77 [file] [log] [blame]
xf.li6c8fc1e2023-08-12 00:11:09 -07001c: Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
2SPDX-License-Identifier: curl
3Long: json
4Arg: <data>
5Help: HTTP POST JSON
6Protocols: HTTP
7See-also: data-binary data-raw
8Mutexed: form head upload-file
9Category: http post upload
10Example: --json '{ "drink": "coffe" }' $URL
11Example: --json '{ "drink":' --json ' "coffe" }' $URL
12Example: --json @prepared $URL
13Example: --json @- $URL < json.txt
14Added: 7.82.0
15Multi: append
16---
17Sends the specified JSON data in a POST request to the HTTP server. --json
18works as a shortcut for passing on these three options:
19
20 --data [arg]
21 --header "Content-Type: application/json"
22 --header "Accept: application/json"
23
24There is **no verification** that the passed in data is actual JSON or that
25the syntax is correct.
26
27If you start the data with the letter @, the rest should be a file name to
28read the data from, or a single dash (-) if you want curl to read the data
29from stdin. Posting data from a file named 'foobar' would thus be done with
30--json @foobar and to instead read the data from stdin, use --json @-.
31
32If this option is used more than once on the same command line, the additional
33data pieces will be concatenated to the previous before sending.
34
35The headers this option sets can be overridden with --header as usual.