0

I have an array of images created with

var a = Array.from(document.getElementById("id").files);

then I want to make a JSON string of that array with

var b = JSON.stringify(a); 

but it produces nothing but an empty array. As I read this is a common problem with stringify but I couldn't find a solution.

Yakir Fitousi
  • 537
  • 3
  • 12
ncpa0cpl
  • 192
  • 1
  • 13

1 Answers1

0

Assuming your array of images are proper File objects, they are a type of binary data called blob.

JSON.Stringify won't work out of the box with blobs, but here is an answer with some workarounds: JSON.stringify or how to serialize binary data as base64 encoded JSON?

Will
  • 482
  • 5
  • 8