Serialize(elem) converts the given element to an abstract,
stringifiable object.

@param {Element} elem
@return {Serialize}
188470
function Serialize (elem) {
  if (!(this instanceof Serialize))
    return new Serialize(elem)

  if (!elem || elem.nodeType !== Node.ELEMENT_NODE)
    throw TypeError('Serialize can only serialize element nodes.')

  var text = ''

  this.length = 0
  this.markups = []
  this.type = elem.nodeName.toLowerCase()

  // Automatically update the length when setting the text.
  Object.defineProperty(this, 'text', {
    configurable: true,
    enumerable: true,
    get: function () {
      return text
    },
    set: function (newText) {
      this.length = newText.length
      text = newText
    }
  })

  convert(elem, this)
}
316444
async def variant(self, elem=None, elem_type=None, params=None, obj=None):
        
        elem_type = elem_type if elem_type else elem.__class__

        if hasattr(elem_type, 'kv_serialize'):
            elem = elem_type() if elem is None else elem
            return await elem.kv_serialize(self, elem=elem, elem_type=elem_type, params=params, obj=obj)

        if self.writing:
            return await self.dump_variant(elem=elem,
                                           elem_type=elem_type if elem_type else elem.__class__, params=params, obj=obj)
        else:
            return await self.load_variant(elem_type=elem_type if elem_type else elem.__class__,
                                           params=params, elem=elem, obj=obj)
716196
private String _serialize(Object object, Map<Object, String> done) throws ConverterException {

	type = "OBJECT";

	String rtn;
	deep++;
	// NULL
	if (object == null) {
	    rtn = goIn() + "";
	    deep--;
	    type = "NULL";
	    return rtn;
	}
	// String
	if (object instanceof String) {
	    rtn = goIn() + XMLUtil.escapeXMLString(object.toString());
	    deep--;
	    type = "STRING";
	    return rtn;
	}
	// Number
	if (object instanceof Number) {
	    rtn = goIn() + ((Number) object).doubleValue();
	    deep--;
	    type = "NUMBER";
	    return rtn;
	}
	// Boolean
	if (object instanceof Boolean) {
	    rtn = goIn() + ((Boolean) object).booleanValue();
	    deep--;
	    type = "BOOLEAN";
	    return rtn;
	}
	// DateTime
	if (object instanceof DateTime) {
	    rtn = _serializeDateTime((DateTime) object);
	    deep--;
	    type = "DATE";
	    return rtn;
	}
	// Date
	if (object instanceof Date) {
	    rtn = _serializeDate((Date) object);
	    deep--;
	    type = "DATE";
	    return rtn;
	}

	Object raw = LazyConverter.toRaw(object);
	String strId = done.get(raw);
	if (strId != null) {
	    rtn = goIn() + "<REF id=\"" + strId + "\"\\>";
	    deep--;
	    type = "NULL";
	    return rtn;
	}
	strId = Caster.toString(++this.id);
	done.put(raw, strId);
	try {
	    // Component
	    if (object instanceof Component) {
		rtn = _serializeComponent((Component) object, done);
		deep--;
		return rtn;
	    }
	    // Struct
	    if (object instanceof Struct) {
		rtn = _serializeStruct((Struct) object, done, strId);
		deep--;
		return rtn;
	    }
	    // Map
	    if (object instanceof Map) {
		rtn = _serializeMap((Map) object, done);
		deep--;
		return rtn;
	    }
	    // Array
	    if (object instanceof Array) {
		rtn = _serializeArray((Array) object, done, strId);
		deep--;
		return rtn;
	    }
	    // List
	    if (object instanceof List) {
		rtn = _serializeList((List) object, done, strId);
		deep--;
		return rtn;
	    }
	    // Query
	    if (object instanceof Query) {
		rtn = _serializeQuery((Query) object, done, strId);
		deep--;
		return rtn;
	    }
	}
	finally {
	    done.remove(raw);
	}
	// Others
	rtn = "<STRUCT ID=\"" + strId + "\" TYPE=\"" + Caster.toTypeName(object) + "\"></STRUCT>";
	deep--;
	return rtn;
    }
1209810
function str_serialize(result, key, value) {
  // encode newlines as \r\n cause the html spec says so
  value = value.replace(/(\r)?\n/g, '\r\n');
  value = encodeURIComponent(value);

  // spaces should be '+' rather than '%20'.
  value = value.replace(/%20/g, '+');
  return result + (result ? '&' : '') + encodeURIComponent(key) + '=' + value;
}
1085241
function serializeFile(file) {

  // preserve path, source, and file-save props
  var o = u.pick(file, 'path', '_oldtext', '_dirty');

  // recreate file.text from serialized fragments
  // new or modifified fragments should delete file.text
  o.text = file.text || serializeTextFragments(file);

  return o;
}
304874
function(elem, options) {
			elem = $(elem);
			if (elem.hasClass(this._getMarker())) {
				return;
			}
			elem.addClass(this._getMarker());
			options = $.extend({}, this.defaultOptions, this._getMetadata(elem), options || {});
			var inst = $.extend({name: this.name, elem: elem, options: options},
				this._instSettings(elem, options));
			elem.data(this.name, inst); // Save instance against element
			this._postAttach(elem, inst);
			this.option(elem, options);
		}
1353252
async def blob(self, elem=None, elem_type=None, params=None):
        
        elem_type = elem_type if elem_type else elem.__class__
        if hasattr(elem_type, 'kv_serialize'):
            elem = elem_type() if elem is None else elem
            return await elem.kv_serialize(self, elem=elem, elem_type=elem_type, params=params)

        if self.writing:
            elem_is_blob = isinstance(elem, x.BlobType)
            data = getattr(elem, x.BlobType.DATA_ATTR) if elem_is_blob else elem
            if data is None:
                return NoSetSentinel()
            if len(data) == 0:
                return b''

            fval = Modeler.to_bytes(data)
            if self.hexlify:
                return binascii.hexlify(fval).decode('ascii')
            else:
                return fval

        else:
            if elem is None:
                return NoSetSentinel()
            if self.hexlify:
                return bytes(binascii.unhexlify(elem))
            else:
                return bytes(elem)
356675
def _serialize(
            self,
            element,  # type: ET.Element
            value,  # type: Dict
            state  # type: _ProcessorState
    ):
        # type: (...) -> None
        """"""
        for child in self._child_processors:
            state.push_location(child.element_path)
            child_value = value.get(child.alias)
            child.serialize_on_parent(element, child_value, state)
            state.pop_location()
530598
function stringify(data){
		switch(typeof data){
			case 'string':
				return '"'+ data.replace(reg_rep, function(a){
					return rep[a];
				}) +'"';
			
			case 'object':
				if(data===null){return 'null'}
				var res = [], k, v;
				if(data instanceof Array){
					var l = data.length;
					for(k = 0; k < l; k++){
						v = stringify(data[k]);
						v===undef || res.push(v);
					}
					return '['+ res.join(',') +']';
				}else{
					for(k in data){
						if(data.hasOwnProperty(k) && k){
							v = stringify(data[k]);
							(jskw[k] || reg_d.test(k)) && (k = '"'+k+'"');
							v===undef || res.push(k +':'+ v);
						}
					}
					return '{'+ res.join(',') +'}';
				}

			case 'number':
				return isFinite(data) ? data.toString() : 'null';
			
			case 'undefined':
			case 'unknown':
				return;
			case 'function':
			case 'boolean':
			case 'regexp':
				return data.toString();
		}
	}
304693
def serialise(self, element: Element) -> str:
        

        return json.dumps(self.serialise_element(element))
1202118
def serialize(element, strip=False):
    
    text = etree.tostring(element, method='text', encoding='utf-8')
    if strip:
        text = text.strip()
    return str(text, encoding='utf-8')
1351098
function (elem)
    {
        var result;

        if (!elem) { return null; }

        if (typeof(elem.tree) === "function") {
            elem = elem.tree();
        }

        var nodeName = elem.nodeName;
        var i, child;

        if (elem.getAttribute("_realname")) {
            nodeName = elem.getAttribute("_realname");
        }

        result = "<" + nodeName;
        for (i = 0; i < elem.attributes.length; i++) {
               if(elem.attributes[i].nodeName != "_realname") {
                 result += " " + elem.attributes[i].nodeName +
                "='" + elem.attributes[i].value
                    .replace(/&/g, "&amp;")
                       .replace(/\'/g, "&apos;")
                       .replace(/>/g, "&gt;")
                       .replace(/</g, "&lt;") + "'";
               }
        }

        if (elem.childNodes.length > 0) {
            result += ">";
            for (i = 0; i < elem.childNodes.length; i++) {
                child = elem.childNodes[i];
                switch( child.nodeType ){
                  case Strophe.ElementType.NORMAL:
                    // normal element, so recurse
                    result += Strophe.serialize(child);
                    break;
                  case Strophe.ElementType.TEXT:
                    // text element to escape values
                    result += Strophe.xmlescape(child.nodeValue);
                    break;
                  case Strophe.ElementType.CDATA:
                    // cdata section so don't escape values
                    result += "<![CDATA["+child.nodeValue+"]]>";
                }
            }
            result += "</" + nodeName + ">";
        } else {
            result += "/>";
        }

        return result;
    }
445298
public static String serialize(Object data) {
        String ret=null;

        if (data != null) {
            if (data.getClass() == String.class) {
                ret = (String)data;
            } else if (data instanceof byte[]) {
                ret = new String((byte[])data);
            } else {
                try {
                    ret = mapper.writeValueAsString(data);
                } catch (JsonProcessingException e) {
                    if (log.isLoggable(Level.FINEST)) {
                        log.log(Level.FINEST, "Failed to serialize object into json", e);
                    }
                }
            }
        }
299697
function (elem)
    {
        // save stream:features for future usage
        this.features = elem;

        var i, child;

        for (i = 0; i < elem.childNodes.length; i++) {
            child = elem.childNodes[i];
            if (child.nodeName == 'bind') {
                this.do_bind = true;
            }

            if (child.nodeName == 'session') {
                this.do_session = true;
            }
        }

        if (!this.do_bind) {
            this._changeConnectStatus(Strophe.Status.AUTHFAIL, null);
            return false;
        } else {
            this._addSysHandler(this._sasl_bind_cb.bind(this), null, null,
                                null, "_bind_auth_2");

            var resource = Strophe.getResourceFromJid(this.jid);
            if (resource) {
                this.send($iq({type: "set", id: "_bind_auth_2"})
                          .c('bind', {xmlns: Strophe.NS.BIND})
                          .c('resource', {}).t(resource).tree());
            } else {
                this.send($iq({type: "set", id: "_bind_auth_2"})
                          .c('bind', {xmlns: Strophe.NS.BIND})
                          .tree());
            }
        }

        return false;
    }
289747
function elemToString(element) {
  return (
    element === null ? 'null' :
    isUndefined(element) ? 'undefined' :
    typeof element !== 'object' ? element.toString() :
    isDate(element) ? element.toISOString() :
    element.toString()
  );
}
1062036
protected function serializeElement($element)
	{
		return (is_array($element)) ? $this->serializeStrings($element) : $this->serializeLiteral($element);
	}
3418
function(map, attr, val) {
	var serializer = attr === "*" ? false : getPropDefineBehavior("serialize", attr, map.define);
	if (serializer === undefined) {
		return oldSingleSerialize.call(map, attr, val);
	} else if (serializer !== false) {
		return typeof serializer === "function" ? serializer.call(map, val, attr) : oldSingleSerialize.call(map, attr, val);
	}
}