data= {
"AgreementId": "131",
"Type": "Admin",
"validFrom": "2020-07-12",
"validTo": "2021-08-10",
"internalDescription": "InternalDescrip",
"customerName": "Test Customer",
}
first step we are converting data to uint8Array then we compressing the data and encding it to base64
const uint8Array = new TextEncoder().encode(JSON.stringify(data))
const compressedData = gzip(uint8Array)
const base64EncodedData = base64Encode(compressedData)
const strData = base64Decode(base64EncodedData);
const charData = strData.split('').map(function(x){return x.charCodeAt(0); });
console.log(charData,"CHARDATA")
const binData = new Uint8Array(charData);
console.log(binData,"BINDATA")
const result = ungzip(binData, { to: 'string' }, { raw: true });
console.log(result,"RESULT");
Then i tried to decompress and decode the array and it s not giving the result . ungzip method is not working . Error: incorrect header check