1*6236dae4SAndroid Build Coastguard Worker--- 2*6236dae4SAndroid Build Coastguard Workerc: Copyright (C) Daniel Stenberg, <[email protected]>, et al. 3*6236dae4SAndroid Build Coastguard WorkerSPDX-License-Identifier: curl 4*6236dae4SAndroid Build Coastguard WorkerLong: json 5*6236dae4SAndroid Build Coastguard WorkerArg: <data> 6*6236dae4SAndroid Build Coastguard WorkerHelp: HTTP POST JSON 7*6236dae4SAndroid Build Coastguard WorkerProtocols: HTTP 8*6236dae4SAndroid Build Coastguard WorkerMutexed: form head upload-file 9*6236dae4SAndroid Build Coastguard WorkerCategory: http post upload 10*6236dae4SAndroid Build Coastguard WorkerAdded: 7.82.0 11*6236dae4SAndroid Build Coastguard WorkerMulti: append 12*6236dae4SAndroid Build Coastguard WorkerSee-also: 13*6236dae4SAndroid Build Coastguard Worker - data-binary 14*6236dae4SAndroid Build Coastguard Worker - data-raw 15*6236dae4SAndroid Build Coastguard WorkerExample: 16*6236dae4SAndroid Build Coastguard Worker - --json '{ "drink": "coffe" }' $URL 17*6236dae4SAndroid Build Coastguard Worker - --json '{ "drink":' --json ' "coffe" }' $URL 18*6236dae4SAndroid Build Coastguard Worker - --json @prepared $URL 19*6236dae4SAndroid Build Coastguard Worker - --json @- $URL < json.txt 20*6236dae4SAndroid Build Coastguard Worker--- 21*6236dae4SAndroid Build Coastguard Worker 22*6236dae4SAndroid Build Coastguard Worker# `--json` 23*6236dae4SAndroid Build Coastguard Worker 24*6236dae4SAndroid Build Coastguard WorkerSends the specified JSON data in a POST request to the HTTP server. --json 25*6236dae4SAndroid Build Coastguard Workerworks as a shortcut for passing on these three options: 26*6236dae4SAndroid Build Coastguard Worker 27*6236dae4SAndroid Build Coastguard Worker --data-binary [arg] 28*6236dae4SAndroid Build Coastguard Worker --header "Content-Type: application/json" 29*6236dae4SAndroid Build Coastguard Worker --header "Accept: application/json" 30*6236dae4SAndroid Build Coastguard Worker 31*6236dae4SAndroid Build Coastguard WorkerThere is **no verification** that the passed in data is actual JSON or that 32*6236dae4SAndroid Build Coastguard Workerthe syntax is correct. 33*6236dae4SAndroid Build Coastguard Worker 34*6236dae4SAndroid Build Coastguard WorkerIf you start the data with the letter @, the rest should be a filename to read 35*6236dae4SAndroid Build Coastguard Workerthe data from, or a single dash (-) if you want curl to read the data from 36*6236dae4SAndroid Build Coastguard Workerstdin. Posting data from a file named 'foobar' would thus be done with --json 37*6236dae4SAndroid Build Coastguard Worker@foobar and to instead read the data from stdin, use --json @-. 38*6236dae4SAndroid Build Coastguard Worker 39*6236dae4SAndroid Build Coastguard WorkerIf this option is used more than once on the same command line, the additional 40*6236dae4SAndroid Build Coastguard Workerdata pieces are concatenated to the previous before sending. 41*6236dae4SAndroid Build Coastguard Worker 42*6236dae4SAndroid Build Coastguard WorkerThe headers this option sets can be overridden with --header as usual. 43