Home > headlines > The author of cURL revealed: cURL will natively support JSON!

The author of cURL revealed: cURL will natively support JSON!

藏色散人
Release: 2022-01-23 09:35:27
forward
2573 people have browsed it

cURL author Daniel Stenberg revealed plans to add native support for JSON to cURL in an email.

The author of cURL revealed: cURL will natively support JSON!

Daniel explained the rationale for adding native support for JSON to cURL:

  • In areas such as REST APIs , sending JSON is very common

  • When many people are asked about considerations for choosing a cURL alternative, "ease of using JSON" is a common one

  • On sites like Stack Overflow, quite a few people are unable to send correct JSON and quote JSON correctly using cURL because JSON uses double quotes and the Shell does not expand variables within single quotes

Daniel also said that since he does not often send JSON, it is not appropriate to rely entirely on him to design this function. He needs help from others to make this feature as useful as possible.

Currently Daniel has provided a draft about this feature in the wiki and created a discussion forum.

In short, Daniel plans to add two command line options:

  • Send formatted JSON as a shortcut to -d with the matching Accept header

  • Send by constructing JSON request body

--json -||@filename
curl --json [whatever] http: //example.com
Copy after login

The above command line is a shortcut and its function is equivalent to- d [whatever] -H "Content-Type: application/json".

--jp [part]
Copy after login

('jp' is the abbreviation of "JSON part")

Build the JSON request body, and then use request headerContent-Type: application/json to send JSON.

[part] are instructions for building JSON content.

(Syntax inspired by jo)

View details: https://github.com/curl/curl/wiki/JSON

Related labels:
source:oschina.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template