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