Convert form names and values to JSON:
489488
function convertObjectToJSON(data) {
      const delimiter = '_'
      let result = {}
      let arrays = {}
      data.forEach(item => {
        const value = item.value
        if (value !== '') {
          if (!item.name) return
          let name = item.name
          let nameParts = name.split(delimiter)
          let currResult = result
          for (let j = 0; j < nameParts.length; j++) {
            const namePart = nameParts[j]
            let arrName
            if (namePart.indexOf('[]') > -1 && j === nameParts.length - 1) {

              arrName = namePart.substr(0, namePart.indexOf('['))
              if (!currResult[arrName]) {
                currResult[arrName] = []
              }
              currResult[arrName].push(value)
            } else {
              if (namePart.indexOf('[') > -1) {
                arrName = namePart.substr(0, namePart.indexOf('['))
                const arrIdx = namePart.replace(/^[a-z]+\[|\]$/gi, '')
                if (!arrays[arrName]) {
                  arrays[arrName] = {}
                }
                if (!currResult[arrName]) {
                  currResult[arrName] = []
                }
                if (j === nameParts.length - 1) {
                  currResult[arrName].push(value)
                } else {
                  if (!arrays[arrName][arrIdx]) {
                    currResult[arrName].push({})
                    arrays[arrName][arrIdx] = currResult[arrName][currResult[arrName].length - 1]
                  }
                }
                currResult = arrays[arrName][arrIdx]
              } else {
                if (j < nameParts.length - 1) {
                  if (!currResult[namePart]) {
                    currResult[namePart] = {}
                  }
                  currResult = currResult[namePart]
                } else {
                  currResult[namePart] = value
                }
              }
            }
          }
        }
      })
      return result
    }
1354140
def fromJSON(value):
        
        j = json.loads(value)
        v = GPRecordSet()
        if "defaultValue" in j:
            v.value = j['defaultValue']
        else:
            v.value = j['value']
        if 'paramName' in j:
            v.paramName = j['paramName']
        elif 'name' in j:
            v.paramName = j['name']
        return v
12150
def json(self):
        """"""
        if self.search_results is None:
            return None

        result = []
        for row in self.search_results['rows']:
            obj = {}
            for index in range(0, len(self.search_results['fields'])):
                obj[self.search_results['fields'][index]] = row[index]
            result.append(obj)

        return result
599870
def to_json(self):
        """"""

        j = {}
        for p in self.properties:
            try:
                v = getattr(self, p)
            except AttributeError:
                continue
            if v is not None:
                if p == 't':
                    j[p] = getattr(self, p).isoformat()
                else:
                    j[p] = getattr(self, p)

        return json.dumps(j)
1223100
def to_json(self):
        

        result = {
            'name': self.name,
            'id': self._real_id(),
            'type': self.type,
            'localized': self.localized,
            'omitted': self.omitted,
            'required': self.required,
            'disabled': self.disabled,
            'validations': [v.to_json() for v in self.validations]
        }

        if self.type == 'Array':
            result['items'] = self.items

        if self.type == 'Link':
            result['linkType'] = self.link_type

        return result
1044741
def as_json(options = {})
      {name: self.name, title: self.title}.merge(options).tap do |options|
        fields.each {|f| options.merge!({f.code_name.to_sym => f.get_value_for(self)})}
      end
    end
1061734
def to_json(self):
        

        web_resp = collections.OrderedDict()

        web_resp['status_code'] = self.status_code
        web_resp['status_text'] = dict(HTTP_CODES).get(self.status_code)
        web_resp['data'] = self.data if self.data is not None else {}
        web_resp['errors'] = self.errors or []

        return web_resp
775589
def fromJSON(value):
        
        j = json.loads(value)
        v = GPLong()
        if "defaultValue" in j:
            v.value = j['defaultValue']
        else:
            v.value = j['value']
        if 'paramName' in j:
            v.paramName = j['paramName']
        elif 'name' in j:
            v.paramName = j['name']
        return v
859357
def formdata_encode(fields):
    
    BOUNDARY = '----form-data-boundary-ZmRkNzJkMjUtMjkyMC00'
    out = []
    for (key, value) in fields.items():
        out.append('--' + BOUNDARY)
        out.append('Content-Disposition: form-data; name="%s"' % key)
        out.append('')
        out.append(value)
    out.append('--' + BOUNDARY + '--')
    out.append('')
    body = '\r\n'.join(out)
    content_type = 'multipart/form-data; boundary=%s' % BOUNDARY
    return content_type, body
932166
def parse_form(self, req, name, field):
        """"""
        return get_value(req.body_arguments, name, field)
923880
def fromJSON(value):
        
        j = json.loads(value)
        v = GPDate()
        if "defaultValue" in j:
            v.value = j['defaultValue']
        else:
            v.value = j['value']
        if 'paramName' in j:
            v.paramName = j['paramName']
        elif 'name' in j:
            v.paramName = j['name']
        #from datetime import datetime
        #if isinstance(value, datetime):
            #v.value = local_time_to_online(value)
        #else:
            #v.value = value
        #v.paramName = j['paramName']
        return v
430093
def get_params(names):
    
    params = {}
    for name in names:
        value = request.form.get(name) or request.files.get(name)
        if value is not None:
            params[name] = value
    return params
189717
def ToJson(self, auto_hex=True):
        
        jsn = {}
        jsn['type'] = str(ContractParameterType(self.Type))

        if self.Type == ContractParameterType.Signature:
            jsn['value'] = self.Value.hex()

        elif self.Type == ContractParameterType.ByteArray:
            if auto_hex:
                jsn['value'] = self.Value.hex()
            else:
                jsn['value'] = self.Value
        elif self.Type == ContractParameterType.Boolean:
            jsn['value'] = self.Value

        elif self.Type == ContractParameterType.String:
            jsn['value'] = str(self.Value)

        elif self.Type == ContractParameterType.Integer:
            jsn['value'] = self.Value

        # @TODO, see ``FromJson``, not sure if this is working properly
        elif self.Type == ContractParameterType.PublicKey:
            jsn['value'] = self.Value.ToString()

        elif self.Type in [ContractParameterType.Hash160,
                           ContractParameterType.Hash256]:
            jsn['value'] = self.Value.ToString()

        elif self.Type == ContractParameterType.Array:

            res = []
            for item in self.Value:
                if item:
                    res.append(item.ToJson(auto_hex=auto_hex))
            jsn['value'] = res

        elif self.Type == ContractParameterType.InteropInterface:
            try:
                jsn['value'] = self.Value.ToJson()
            except Exception as e:
                pass

        return jsn
541948
def fill_form(form, data):
    
    for (key, value) in data.items():
        if hasattr(form, key):
            if isinstance(value, dict):
                fill_form(getattr(form, key), value)
            else:
                getattr(form, key).data = value
    return form
1103286
def _gen_form_data(self) -> multipart.MultipartWriter:
        """"""
        for dispparams, headers, value in self._fields:
            try:
                if hdrs.CONTENT_TYPE in headers:
                    part = payload.get_payload(
                        value, content_type=headers[hdrs.CONTENT_TYPE],
                        headers=headers, encoding=self._charset)
                else:
                    part = payload.get_payload(
                        value, headers=headers, encoding=self._charset)
            except Exception as exc:
                raise TypeError(
                    'Can not serialize value type: %r\n '
                    'headers: %r\n value: %r' % (
                        type(value), headers, value)) from exc

            if dispparams:
                part.set_content_disposition(
                    'form-data', quote_fields=self._quote_fields, **dispparams
                )
                # FIXME cgi.FieldStorage doesn't likes body parts with
                # Content-Length which were sent via chunked transfer encoding
                assert part.headers is not None
                part.headers.popall(hdrs.CONTENT_LENGTH, None)

            self._writer.append_payload(part)

        return self._writer
1230563
function toJSON() {
      const model = this.toObject()
      delete model.password
      delete model.salt

      // Return the modified user object.
      return utils.remove_null_undefined(model)
    }
582792
def fromJSON(value):
        """"""
        if isinstance(value, str):
            value = json.loads(value)
        elif isinstance(value, dict): pass
        else:
            raise AttributeError("Invalid input")
        return Extension(typeName=value['typeName'],
                         capabilities=value['capabilities'],
                         enabled=value['enabled'] == "true",
                         maxUploadFileSize=value['maxUploadFileSize'],
                         allowedUploadFileType=value['allowedUploadFileTypes'],
                         properties=value['properties'])