Read contents of Byte array containing JSON file

Hi all,

Does anyone know how to convert a byte array which contains a JSON file in such a way that the contents can be processed by N8N?

The data is coming from the API https://api.crayon.com/api/v1/billingstatements/{id}/billingrecordsfile/ (documentation) .

I tried to convert the byte array to binary using the code below (and other suggestions from Stack Overflow) and fed the result into node “Move Binary Data” → Binary to JSON, but the node did not return any data.

    const buffer = Buffer.from(item.json.body.data);
    binary = BigInt('0x' + buffer.toString('hex')).toString(2).padStart(buffer.length * 8, '0');

I also tried to use Blob, but that did not work..

We are using N8N.cloud, 0.186.1 (latest stable)

Hi @Gerbert, welcome to the community!

Tbh, I am having a hard time understanding the format. They say it’s a byte array but I don’t think I’ve seen a format like IJQRJwzoQUcB2ZpLajtr... in their example before. I’ll see if I can figure out how to read this.

Does the response change when you send a Accept: application/json header with your request?

Thanks MutedJam, love the product (and recommend it regularly to other members of the Bubble.io community).

Tried it with Accept=application/json as a header, no change, the contents of the response were exactly the same.

Thanks for having helping so far. I’ll keep on trying various solutions.

1 Like

@MutedJam, it turns out the contents were Base64 encoded. Using your solution I was able to get to the JSON, thanks man!

1 Like