var ospf = JSON.parse(value);

ospf.forEach(function (item, index, array) {
	var ip = item["{#OSPFV3_IP_ADDR}"];
	var parts = ip.trim().split(' ');

	if (parts.length === 4) {
		for (var i = 0; i < parts.length; ++i) {
			parts[i] = parseInt(parts[i], 16);
		}
		ip = parts.join('.');
	}
	else if (parts.length == 16) {
		var ipSegments = [];
		for (var i = 0; i < parts.length; i += 4) {
			var ipv6 = parts.slice(i, i + 4).join('');
			ipv6 = parseInt(ipv6, 16).toString(16);
			ipSegments.push(ipv6 || '0');
		}
		ip = ipSegments.join(':').toLowerCase();

		var maxZeros = 0, currZeros = 0, startIdx = -1, maxStartIdx = -1;
		for (i = 0; i < ipSegments.length; i++) {
			if (ipSegments[i] === '0') {
				if (currZeros === 0) startIdx = i;
				currZeros++;
			} else {
				if (currZeros > maxZeros) {
					maxZeros = currZeros;
					maxStartIdx = startIdx;
				}
				currZeros = 0;
			}
		}
		if (currZeros > maxZeros) {
			maxZeros = currZeros;
			maxStartIdx = startIdx;
		}
		if (maxZeros > 1) {
			ipSegments.splice(maxStartIdx, maxZeros, '');
			ip = ipSegments.join(':').replace(/(^:|:$)/, '');
		}
	}

	array[index]["{#OSPFV3_IP_ADDR}"] = ip;
});

return JSON.stringify(ospf);