I am attempting to convert a blob file into JSON format in order to transmit it via AJAX requests. Despite my efforts with the code below, I have not been successful in achieving this task. When I attempt to parse the JSONified file, I end up with a completely different file that is much smaller in size.
function convertBlobToJSON(blob, callback) {
var fileReader = new FileReader()
fileReader.readAsArrayBuffer(blob)
fileReader.onloadend = function() {
// Client-side
var array = Array.from(new Uint8Array(fileReader.result))
var data = {data: array }
var json = JSON.stringify(data)
// Server-side
var parsedData = JSON.parse(json)
var byteArray = parsedData.data.buffer
var blobData = new Blob([byteArray])
}
}