How do I send data using JSON as output format? There are separate web forms created on the basis of the Webform module (Drupal 7), sending by default goes to the required e-mail. Everything is within the module.

In addition, there was a need to send the data of the webform application (field) to various CRM (custom) based on JSON.

Request format

{
    "aCode": "zzz",
    "importdata": {
        "id": "zzz",
        "user_data": {
            "name": "zzz",
        },
        "contact": {
            "phone": "zzz",
        }
    }
}


How do I properly implement this functionality?

Process:

External url for accepting JSON lead requests (example): http://example-server.com:8083/api/submit

After the webform has been filled in, it is necessary to automatically send the field data in the raw postdata format to the external CRM with the JSON request format specified above in the code.
You will need to write a custom module that will select data from the webform tables in the database, encode your response and then call the URL

$crmurl = 'http://www.crmdomain.com/api/datafromdrupal';

if (isset($response)) {
  $json_response = drupal_json_encode($response); /* Pure json encoding */

  $options = array(
             'method' =&gt; 'POST',
             'data' =&gt; $json_response,
             'timeout' =&gt; 15,
             'headers' =&gt; array('Content-Type' =&gt; 'application/x-www-form-
             urlencoded'),);
  $result = drupal_http_request($crmurl, $options);
}