How to place an image in json

Asked

Viewed 640 times

0

Hello

i am trying to put data in json an image and then in html appear a title a location a text and an image, but I already tried url() and src but I can’t put it there...

[
    {
        "titulo": "Exemplo",
        "localizacao": "Rua de Exemplo",
        "Texto": "Texto grande de exemplo para usar como teste",
        "imagem": ,
    }
]

the goal and appear like this in html

TITLE localization large sample text image

but within a div, my only doubt is whether there is any way to put an image inside the json because I will use json as a database

  • yes, you can have in json the image link or the bytes of the image, just convert to base64 which is then simple to do the opposite process and include in the div

1 answer

2

In this case, you can put the image on base64. When you choose an image in a <input type="file">, you can capture the base64 hers.

  • i used an online converter to convert an image to Base64 but it gets great the image code and vs code does not read

  • 1

    You have some kind of form on your page for the user to pass information on title, location, sample large text and image?

  • 1

    I already found a solution without using Base64 but thanks anyway!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.