var inputArray = JSON.parse(value);

var transformedArray = inputArray.reduce(function (acc, item) {
	var snmpIndex = item["{#SNMPINDEX}"];
	var mainIndex = snmpIndex.split('.')[0];

	if (item["{#LANEINDEX}"] !== undefined) {
		var portData = null;

		for (var i = 0; i < inputArray.length; i++) {
			if (inputArray[i]["{#SNMPINDEX}"] === mainIndex) {
				portData = inputArray[i];
				break;
			}
		}

		if (portData) {
			acc.push(Object.assign(
				{},
				item,
				{ "{#PORTINDEX}": mainIndex },
				portData
			));
		}
	}
	return acc;
}, []);

return JSON.stringify(transformedArray);