parse body from hash to xml format
779204
def to_xml(body)
        root = @api_options[:root_element].nil? ? 'Request' : @api_options[:root_element]
        body.to_xml(root: root, skip_instruct: true, skip_types: true)
      end
191149
def form_body
      if body.is_a?(Hash)
        body.map do |k,v|
          [AwsRequest.aws_encode(k), AwsRequest.aws_encode(v)].join("=")
        end.join("&")
      else
        body
      end
    end
365729
private void parseBodyAttributes() {
        if (!undecodedChunk.hasArray()) {
            parseBodyAttributesStandard();
            return;
        }
        SeekAheadOptimize sao = new SeekAheadOptimize(undecodedChunk);
        int firstpos = undecodedChunk.readerIndex();
        int currentpos = firstpos;
        int equalpos;
        int ampersandpos;
        if (currentStatus == MultiPartStatus.NOTSTARTED) {
            currentStatus = MultiPartStatus.DISPOSITION;
        }
        boolean contRead = true;
        try {
            loop: while (sao.pos < sao.limit) {
                char read = (char) (sao.bytes[sao.pos++] & 0xFF);
                currentpos++;
                switch (currentStatus) {
                case DISPOSITION:// search '='
                    if (read == '=') {
                        currentStatus = MultiPartStatus.FIELD;
                        equalpos = currentpos - 1;
                        String key = decodeAttribute(undecodedChunk.toString(firstpos, equalpos - firstpos, charset),
                                charset);
                        currentAttribute = factory.createAttribute(request, key);
                        firstpos = currentpos;
                    } else if (read == '&') { // special empty FIELD
                        currentStatus = MultiPartStatus.DISPOSITION;
                        ampersandpos = currentpos - 1;
                        String key = decodeAttribute(
                                undecodedChunk.toString(firstpos, ampersandpos - firstpos, charset), charset);
                        currentAttribute = factory.createAttribute(request, key);
                        currentAttribute.setValue(""); // empty
                        addHttpData(currentAttribute);
                        currentAttribute = null;
                        firstpos = currentpos;
                        contRead = true;
                    }
                    break;
                case FIELD:// search '&' or end of line
                    if (read == '&') {
                        currentStatus = MultiPartStatus.DISPOSITION;
                        ampersandpos = currentpos - 1;
                        setFinalBuffer(undecodedChunk.copy(firstpos, ampersandpos - firstpos));
                        firstpos = currentpos;
                        contRead = true;
                    } else if (read == HttpConstants.CR) {
                        if (sao.pos < sao.limit) {
                            read = (char) (sao.bytes[sao.pos++] & 0xFF);
                            currentpos++;
                            if (read == HttpConstants.LF) {
                                currentStatus = MultiPartStatus.PREEPILOGUE;
                                ampersandpos = currentpos - 2;
                                sao.setReadPosition(0);
                                setFinalBuffer(undecodedChunk.copy(firstpos, ampersandpos - firstpos));
                                firstpos = currentpos;
                                contRead = false;
                                break loop;
                            } else {
                                // Error
                                sao.setReadPosition(0);
                                throw new ErrorDataDecoderException("Bad end of line");
                            }
                        } else {
                            if (sao.limit > 0) {
                                currentpos--;
                            }
                        }
                    } else if (read == HttpConstants.LF) {
                        currentStatus = MultiPartStatus.PREEPILOGUE;
                        ampersandpos = currentpos - 1;
                        sao.setReadPosition(0);
                        setFinalBuffer(undecodedChunk.copy(firstpos, ampersandpos - firstpos));
                        firstpos = currentpos;
                        contRead = false;
                        break loop;
                    }
                    break;
                default:
                    // just stop
                    sao.setReadPosition(0);
                    contRead = false;
                    break loop;
                }
            }
            if (isLastChunk && currentAttribute != null) {
                // special case
                ampersandpos = currentpos;
                if (ampersandpos > firstpos) {
                    setFinalBuffer(undecodedChunk.copy(firstpos, ampersandpos - firstpos));
                } else if (!currentAttribute.isCompleted()) {
                    setFinalBuffer(EMPTY_BUFFER);
                }
                firstpos = currentpos;
                currentStatus = MultiPartStatus.EPILOGUE;
            } else if (contRead && currentAttribute != null && currentStatus == MultiPartStatus.FIELD) {
                // reset index except if to continue in case of FIELD getStatus
                currentAttribute.addContent(undecodedChunk.copy(firstpos, currentpos - firstpos),
                                            false);
                firstpos = currentpos;
            }
            undecodedChunk.readerIndex(firstpos);
        } catch (ErrorDataDecoderException e) {
            // error while decoding
            undecodedChunk.readerIndex(firstpos);
            throw e;
        } catch (IOException e) {
            // error while decoding
            undecodedChunk.readerIndex(firstpos);
            throw new ErrorDataDecoderException(e);
        } catch (IllegalArgumentException e) {
            // error while decoding
            undecodedChunk.readerIndex(firstpos);
            throw new ErrorDataDecoderException(e);
        }
    }
900995
function parseBody()
    {
        $request = $this->getMessageObject();

        $reqID   = spl_object_hash($request);
        if ( isset(self::$_parsed[$reqID]) )
            // parse from cached
            return self::$_parsed[$reqID];

        if ($request->headers()->has('content-type')) {
            $contentType = \Poirot\Http\Header\renderHeaderValue($request, 'content-type');
            $contentType = strtolower($contentType);

        } else {
            // No Any Data Sent .....
            return array();
        }


        // Content-Type May be in form of:
        // application/x-www-form-urlencoded; charset=utf-8
        // when we call from jquery/ajax in exm.
        if ( false !== $pos = strpos($contentType, ';') )
            $contentType = substr($contentType, 0, $pos);


        switch ( $contentType )
        {
            case 'application/json':
                $parsedData = $this->_parseJsonDataFromRequest($request);
                break;

            case 'application/x-www-form-urlencoded':
                $parsedData = $this->_parseUrlEncodeDataFromRequest($request);
                break;
            case strpos($contentType, 'multipart') !== false:
                $parsedData = $this->_parseMultipartDataFromRequest($request);
                break;

            default:
                throw new \Exception(sprintf(
                    'Request Body Contains No Data or Unknown Content-Type (%s).'
                    , $contentType
                ));
        }


        return self::$_parsed[$reqID] = $parsedData;
    }
230706
private function parse($body)
    {
        $xmlObject = simplexml_load_string($body);
        foreach ($xmlObject as $key => $value) {
            $response[$key] = (string) $value;
        }

        return $response;
    }
1109748
def parse_posts_dates_response(body)
        dom = parse_and_validate_response(body, :root_name => 'dates')
        dom.root.get_elements('date').inject({}) do |collection, xml|
          date  = xml.if_attribute_value(:date)
          count = xml.if_attribute_value(:count)
          collection.merge({ date => count })
        end
      end
614919
def decode_body(headers: MutableMapping, body: bytes) -> dict:
    

    type_, encoding = parse_content_type(headers)
    decoded_body = body.decode(encoding)

    # There is one api that just returns `ok` instead of json. In order to have a consistent API we decided to modify the returned payload into a dict.
    if type_ == "application/json":
        payload = json.loads(decoded_body)
    else:
        if decoded_body == "ok":
            payload = {"ok": True}
        else:
            payload = {"ok": False, "data": decoded_body}

    return payload
764907
def convert_hash_body_to_array_of_arrays
      arrays = []
      request.body.keys.each do | key |
        [*request.body[key]].each do | value |
          arrays << [key, value]
        end
      end

      Pact::Reification.from_term(arrays)
    end
1342537
def to_a
      hash = {}
      @to_a ||=
        elements_with_tags.map.with_index do |(el, tag_name), idx|
          selector = @selector.dup
          selector[:index] = idx unless idx.zero?
          element = element_class.new(@query_scope, selector)
          if [HTMLElement, Input].include? element.class
            construct_subtype(element, hash, tag_name).tap { |e| e.cache = el }
          else
            element.tap { |e| e.cache = el }
          end
        end
    end
1266099
def parse_bundle_collection(body)
        dom = parse_and_validate_response(body, :root_name => 'bundles')
        dom.root.elements.collect('bundle') { |xml| Bundle.from_rexml(xml) }
      end
481177
def formatBodyNode(root,path):
    ''''''
    body        = root
    body.name   = "body"
    body.weight = calcFnWeight(body)
    body.path   = path
    body.pclass = None
    return body
452962
def body
      if raw_post = get_header("RAW_POST_DATA")
        raw_post = raw_post.dup.force_encoding(Encoding::BINARY)
        StringIO.new(raw_post)
      else
        body_stream
      end
    end
432978
function parseHashToObject(sHash){
			if (isVirtualHash(sHash)) {
				var i = sHash.lastIndexOf(skipSuffix);
				sHash = sHash.slice(0, i);
			}


			var aParts = sHash.split(sIdSeperator), oReturn = {};
			if (aParts.length === 4 || aParts.length === 3) {
				oReturn.sIdentifier = window.decodeURIComponent(aParts[0]);
				oReturn.oStateData = window.JSON.parse(window.decodeURIComponent(aParts[1]));
				if (aParts.length === 4) {
					oReturn.uid = aParts[2];
				}

				oReturn.bBookmarkable = aParts[aParts.length - 1] === "0" ? false : true;

				return oReturn;
			} else {
				//here can be empty hash only with a skipable suffix
				return null;
			}
		}
1351273
private Map<String, Object> getBodyAsDictionary() throws CouchbaseLiteException {
        // check if content-type is `application/json`
        String contentType = getRequestHeaderContentType();
        if (contentType != null && !contentType.equals(CONTENT_TYPE_JSON))
            throw new CouchbaseLiteException(Status.NOT_ACCEPTABLE);

        // parse body text
        // NOTE: contentStream should not be close immediately. It will close Socket connection.
        InputStream contentStream = connection.getRequestInputStream();
        try {
            return Manager.getObjectMapper().readValue(contentStream, Map.class);
        } catch (JsonParseException jpe) {
            throw new CouchbaseLiteException(Status.BAD_JSON);
        } catch (JsonMappingException jme) {
            throw new CouchbaseLiteException(Status.BAD_JSON);
        } catch (IOException ioe) {
            throw new CouchbaseLiteException(Status.REQUEST_TIMEOUT);
        }
    }
890049
def body
      if content_type_is_form && request.body.is_a?(Hash)
        URI.encode_www_form convert_hash_body_to_array_of_arrays
      else
        Pact::Reification.from_term(request.body)
      end
    end
229754
function parseHeader(header_text) {
  var doc = new _xmldom.DOMParser().parseFromString(header_text, "text/xml");
  var header_attr = {};
  var elem = doc.getElementsByTagName("Dictionary")[0];
  if (!elem) {
    elem = doc.getElementsByTagName("Library_Data")[0]; // eslint_disable_prefer_destructing
  }
  for (var i = 0, item; i < elem.attributes.length; i++) {
    item = elem.attributes[i];
    header_attr[item.nodeName] = item.nodeValue;
  }
  return header_attr;
}
1001993
def __body_format(self, body):
        

        ctype, pdict = parse_header(self.content_type)
        if ctype == 'application/json':
            self.form = json.loads(body.decode())

        elif ctype == 'application/x-www-form-urlencoded':
            for key, value in parse_qs(body).items():
                    self.form[key.decode()] = [one_value.decode() for one_value in value]

        elif ctype == "multipart/form-data":
            safe_env = {
                'QUERY_STRING': '',
                'REQUEST_METHOD': self.method.upper(),
                'CONTENT_TYPE': self.content_type,
                'CONTENT_LENGTH': self.headers.get('Content-Length', '-1')
            }
            fields = FieldStorage(io.BytesIO(body), environ=safe_env, keep_blank_values=True)

            fields = fields.list or []
            for field in fields:
                if field.filename:
                    self.form[field.name] = File(field.filename, field.file)
                else:
                    self.form[field.name] = field.value