cURL author Daniel Stenberg emailed revealed about plans to add native support for JSON to cURL.
Daniel explains the reasons for adding native JSON support to cURL:
- sending JSON is a common practice in areas such as REST APIs
- “Ease of use with JSON” was a common consideration when many people were asked about choosing a cURL alternative
- on sites like Stack Overflow, a significant number of people were unable to send the correct JSON and quote JSON correctly using cURL because JSON uses double quotes and the Shell does not expand variables inside single quotes
Daniel also said that since he doesn’t send JSON very often, it wasn’t appropriate to rely entirely on him to design this feature. He needs help from others to make this feature as useful as possible.
In brief, Daniel plans to add two command line options.
- send a formatted JSON as a shortcut to -d, with a matching Accept header
- send by constructing a JSON request body
The above command line is a shortcut that is equivalent to
-d [whatever] -H "Content-Type: application/json" .
(‘jp’ is short for “JSON part”)
Construct the JSON request body and then send the JSON using the request header
[part] is the command to build the JSON content.
(Syntax inspired by jo)
See more: https://github.com/curl/curl/wiki/JSON