Skip to content Skip to sidebar Skip to footer

Converting A Response Buffer To Json

In AWS, I am issuing a get request through Lambda with the https module. I am able to return the data, but it is in the buffer format when I call callback(null, obj) https.get(opti

Solution 1:

I figured it out. With tomfa's code found here: BinArraytoJson I simply did:

var binArrayToJson = function(binArray) {
    var str = "";
    for (var i = 0; i < binArray.length; i++) {
        str += String.fromCharCode(parseInt(binArray[i]));
    } 
    returnJSON.parse(str)
}

Then: JSON.parse(binArrayToJson(yourBinArray));

Post a Comment for "Converting A Response Buffer To Json"