json.d 1.3 KB

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