xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame] | 1 | c: Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. |
| 2 | SPDX-License-Identifier: curl |
| 3 | Long: json |
| 4 | Arg: <data> |
| 5 | Help: HTTP POST JSON |
| 6 | Protocols: HTTP |
| 7 | See-also: data-binary data-raw |
| 8 | Mutexed: form head upload-file |
| 9 | Category: http post upload |
| 10 | Example: --json '{ "drink": "coffe" }' $URL |
| 11 | Example: --json '{ "drink":' --json ' "coffe" }' $URL |
| 12 | Example: --json @prepared $URL |
| 13 | Example: --json @- $URL < json.txt |
| 14 | Added: 7.82.0 |
| 15 | Multi: append |
| 16 | --- |
| 17 | Sends the specified JSON data in a POST request to the HTTP server. --json |
| 18 | works 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 | |
| 24 | There is **no verification** that the passed in data is actual JSON or that |
| 25 | the syntax is correct. |
| 26 | |
| 27 | If you start the data with the letter @, the rest should be a file name to |
| 28 | read the data from, or a single dash (-) if you want curl to read the data |
| 29 | from 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 | |
| 32 | If this option is used more than once on the same command line, the additional |
| 33 | data pieces will be concatenated to the previous before sending. |
| 34 | |
| 35 | The headers this option sets can be overridden with --header as usual. |