json.d 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  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. ---
  16. Sends the specified JSON data in a POST request to the HTTP server. --json
  17. works as a shortcut for passing on these three options:
  18. --data [arg]
  19. --header "Content-Type: application/json"
  20. --header "Accept: application/json"
  21. There is **no verification** that the passed in data is actual JSON or that
  22. the syntax is correct.
  23. If you start the data with the letter @, the rest should be a file name to
  24. read the data from, or a single dash (-) if you want curl to read the data
  25. from stdin. Posting data from a file named \&'foobar' would thus be done with
  26. --json @foobar and to instead read the data from stdin, use --json @-.
  27. If this option is used more than once on the same command line, the additional
  28. data pieces will be concatenated to the previous before sending.
  29. The headers this option sets can be overridden with --header as usual.