index.js
function (data) {
        var type = $this.options.headers[$this.hasHeader('content-type')]

        if ((is(data).a(Object) || is(data).a(Array)) && !Buffer.isBuffer(data)) {
          if (!type) {
            $this.type('form')
            type = $this.options.headers[$this.hasHeader('content-type')]
            $this.options.body = Unirest.serializers.form(data)
          } else if (~type.indexOf('json')) {
            $this.options.json = true

            if ($this.options.body && is($this.options.body).a(Object)) {
              for (var key in data) {
                if (Object.prototype.hasOwnProperty.call(data, key)) {
                  $this.options.body[key] = data[key]
                }
              }
            } else {
              $this.options.body = data
            }
          } else {
            $this.options.body = Unirest.Request.serialize(data, type)
          }
        } else if (is(data).a(String)) {
          if (!type) {
            $this.type('form')
            type = $this.options.headers[$this.hasHeader('content-type')]
          }

          if (type === 'application/x-www-form-urlencoded') {
            $this.options.body = $this.options.body
              ? $this.options.body + '&' + data
              : data
          } else {
            $this.options.body = ($this.options.body || '') + data
          }
        } else {
          $this.options.body = data
        }

        return $this
      }
function (data) {
        var type = $this.options.headers[$this.hasHeader('content-type')]

        if ((is(data).a(Object) || is(data).a(Array)) && !Buffer.isBuffer(data)) {
          if (!type) {
            $this.type('form')
            type = $this.options.headers[$this.hasHeader('content-type')]
            $this.options.body = Unirest.serializers.form(data)
          } else if (~type.indexOf('json')) {
            $this.options.json = true

            if ($this.options.body && is($this.options.body).a(Object)) {
              for (var key in data) {
                if (Object.prototype.hasOwnProperty.call(data, key)) {
                  $this.options.body[key] = data[key]
                }
              }
            } else {
              $this.options.body = data
            }
          } else {
            $this.options.body = Unirest.Request.serialize(data, type)
          }
        } else if (is(data).a(String)) {
          if (!type) {
            $this.type('form')
            type = $this.options.headers[$this.hasHeader('content-type')]
          }

          if (type === 'application/x-www-form-urlencoded') {
            $this.options.body = $this.options.body
              ? $this.options.body + '&' + data
              : data
          } else {
            $this.options.body = ($this.options.body || '') + data
          }
        } else {
          $this.options.body = data
        }

        return $this
      }
function ( data ) { var type = $this . options . headers [ $this . hasHeader ( 'content-type' ) ] if ( ( is ( data ) . a ( Object ) || is ( data ) . a ( Array ) ) && ! Buffer . isBuffer ( data ) ) { if ( ! type ) { $this . type ( 'form' ) type = $this . options . headers [ $this . hasHeader ( 'content-type' ) ] $this . options . body = Unirest . serializers . form ( data ) } else if ( ~ type . indexOf ( 'json' ) ) { $this . options . json = true if ( $this . options . body && is ( $this . options . body ) . a ( Object ) ) { for ( var key in data ) { if ( Object . prototype . hasOwnProperty . call ( data , key ) ) { $this . options . body [ key ] = data [ key ] } } } else { $this . options . body = data } } else { $this . options . body = Unirest . Request . serialize ( data , type ) } } else if ( is ( data ) . a ( String ) ) { if ( ! type ) { $this . type ( 'form' ) type = $this . options . headers [ $this . hasHeader ( 'content-type' ) ] } if ( type === 'application/x-www-form-urlencoded' ) { $this . options . body = $this . options . body ? $this . options . body + '&' + data : data } else { $this . options . body = ( $this . options . body || '' ) + data } } else { $this . options . body = data } return $this }
Data marshalling for HTTP request body data

Determines whether type is `form` or `json`.
For irregular mime-types the `.type()` method is used to infer the `content-type` header.

When mime-type is `application/x-www-form-urlencoded` data is appended rather than overwritten.

@param  {Mixed} data
@return {Object}
Data marshalling for HTTP request body data