Edit and cut the json output of a node

Describe the issue/error/question


Hello friends, my problem is the following: I am trying to visualize a qr code that I receive in base64 format, I have almost everything ready but the problem is that the node that gives me the qr code does not include the clean base64 code, that is, the base64 code It comes with some words and symbols at the beginning that generate a conflict to display the image in the next node.

So I need to exclude the words and symbols that generate this conflict for me.

The output of my node is:

data:image/png;base64,{code_qr_on_base64}

And I need to remove:

“data:image/png;base64,”

To leave only:

{code_qr_on_base64}


Share the output returned by the last node

[

{

“qrCode”:“data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAARQAAAEUCAYAAADqcMl5AAAAAklEQVR4AewaftIAABIASURBVO3BQW7oyrLgQFLw/rfMPsMcFSCo7Pt+IyPsH9Za64KHtda65GGttS55WGutSx7WWuuSh7XWuuRhrbUueVhrrUse1lrrkoe11rrkYa21LnlYa61LHtZa65KHtda65GGttS55WGutS374SOUvVUwqJxWTyknFicpJxRsqU8WJyknFGypTxaRyUvGGylQxqUwVk8pUMamcVNykMlWcqJxUTCp/qeKLh7XWuuRhrbUueVhrrUt+uKziJpW/pPKFyknFVPFGxRsqU8WJyknFpDJVTCpTxaQyVXxRcaIyVZyovKEyVdxUcZPKTQ9rrXXJw1prXfKw1lqX/PDLVN6oeKPiRGWq+Esqk8pUMalMFTepTBWTylRxUjGpTBWTylRxojJVTCpvVEwqJxWTyhsqv0nljYrf9LDWWpc8rLXWJQ9rrXXJD//HqZxUvKEyVUwqJxUnFb9JZao4UTlRmSreUDlRmSreqPiiYlKZVG6qmFT+f/Kw1lqXPKy11iUPa611yQ//x1V8oXKiMlW8UTGpfKEyVfwllZsqJpWp4guVk4ovKiaVE5Wp4v8nD2utdcnDWmtd8rDWWpf88Msq/pLKVPFFxYnKVPFGxf+SijdUpopJZaqYVN5QmSpOKk5UpopJ5Y2KSWWquKnif8nDWmtd8rDWWpc8rLXWJT9cpvKXVKaKSWWqOKmYVKaKN1SmikllqphUpopJZaqYVKaKN1Smit9UMalMFZPKVDGpTBVfVEwqU8UbKlPFicr/soe11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UcaLyRsUXKl9UTCq/qeINlaniJpU3Kt5QOamYVG6qOFGZKm56WGutSx7WWuuSh7XWuuSHjyp+U8UXKlPFScUbFV+onFScVEwqJyonFW+oTBWTylTxhcobFV+onFRMFV9UvKHyv+RhrbUueVhrrUse1lrrkh8+UvlLFScVk8qkMlWcqJxUnKi8UTGpnKhMFZPKVDGpnKhMFV+ovKFyUjGpvFExqZxUfKHyhspUcaIyVZyoTBVfPKy11iUPa611ycNaa13yw2UVN6l8UfGXVKaKmyr+UsUXFTepnFS8oTJVTCqTylRxovJFxf8lD2utdcnDWmtd8rDWWpf88MtU3qh4o+JE5aRiUpkqTlTeUPlCZao4qXhD5SaVqeINlaliUpkqJpWTikllqphUTlROKiaVSeWLipOKSeWmh7XWuuRhrbUueVhrrUt++D9OZao4qZhUTlSmipOKSeWk4kTlROWLiknljYpJZaqYVN6oOKmYVH5TxRsVk8pUMal8oTJV/KWHtda65GGttS55WGutS374/4zKicpJxaRyUvFGxYnKScUbKl9UnKhMFZPKScWJylRxUvGGyonKVDGpTBWTyk0Vk8pUcaIyVdz0sNZalzystdYlD2utdYn9wwcqU8VNKlPFFypTxYnKVDGpfFHxhcpU8YbKb6qYVG6qmFSmikllqvhLKlPFpDJVTCpTxaRyUvGbHtZa65KHtda65GGttS754TKVv6QyVfwmlaliUnlDZaqYVH5TxaTyRsUbFZPKScWk8obKTSpvVEwVJxUnFZPKGyonFV88rLXWJQ9rrXXJw1prXWL/sNZaFzystdYlD2utdcnDWmtd8rDWWpc8rLXWJQ9rrXXJw1prXfKw1lqXPKy11iUPa611ycNaa13ysNZalzystdYlD2utdcnDWmtd8v8AnDtqUOotuOwAAAAASUVORK5CYII=”

}

]


This is how the output looks on my screen and I marked in red what I need to delete so that it does not give me problems when viewing the image

Information on your n8n setup

  • 0.202.1
  • Running n8n via Docker

You should just be able to do a replace on the string


return [
  {
  json: {
    
  },
  binary: {
    data: {
      data: $json["qrCode"].replace("data:image/png;base64,", ""),
      mimeType: "image/jpeg",
      fileExtension: 'jpeg',
      fileName: "qrcode.jpeg"
    }
  }
  }
]
2 Likes

Thank you very much, its working :blush:

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.