Serializes a JS object into key/value pairs.