var data = JSON.parse(value),
	dns = getField(data, 'dnsGroup'),
	dns_servers = [];

function getField(data, path, defaultValue) {
	var steps = path.split('.'),
		step = steps.shift();

	while (typeof step !== 'undefined') {
		if (typeof data === 'undefined' || typeof data[step] === 'undefined') {
			return defaultValue;
		}

		data = data[step];
		step = steps.shift();
	}
	return data;
};

dns.forEach(function (item) {

	var group = getField(item, "name"),
		type = getField(item, "type"),
		servers = getField(item, "server", {}),
		servers = Array.isArray(servers) ? servers : [servers];

	servers.forEach(function (server) {
		dns_servers.push({
			"{#DNS.GROUP}": group,
			"{#DNS.TYPE}": type,
			"{#DNS.SERVER}": getField(server, "name", ''),
			"{#DNS.IP}": getField(server, "ipAddress", ''),
			"{#DNS.STATE}": getField(server, "state", '')
		});
	});
});

return JSON.stringify(dns_servers);