var parts = value.split(']]>]]>'),
	results = [],
	skipped_parts = [];

function cleanObject(obj) {
	if (Array.isArray(obj)) {
		return obj.map(cleanObject);
	} else if (typeof obj === 'object' && obj !== null) {
		var cleaned_obj = {};
		for (var key in obj) {
			if (obj.hasOwnProperty(key)) {
				cleaned_obj[key] = cleanObject(obj[key]);
			}
		}
		return cleaned_obj;
	} else if (typeof obj === 'string') {
		return obj.replace(/\n/g, "");
	}
	return obj;
};

for (var i = 0; i < parts.length; i++) {
	var part = parts[i].trim();
	if (part) {
		if (part.startsWith('<!--') && part.endsWith('-->')) {
			skipped_parts.push({ skipped: 'comment in XML', content: part });
			continue
		}

		try {
			results.push(JSON.parse(XML.toJson(part)));
		} catch (error) {
			results.push({ error: "Failed to parse XML response " + i, content: part });
		}
	}
};

results = cleanObject(results);

return JSON.stringify({ results, skipped_parts });