0

I Want to load image from json in my assest as a string and then pass it to an imageview. How to do it?

  • Not sure what you are asking but does https://stackoverflow.com/questions/34485420/how-do-you-put-an-image-file-in-a-json-object answer your question? – Scary Wombat Feb 09 '22 at 06:00

3 Answers3

1

Say your json is something like:

const book = {
id: 1,
title: "my title",
img:"/image/file.png",
...
}
...

you may pass that object directly in your image tag:

eg.

<img src="{book.img}" />
NJAS
  • 53
  • 5
0

You can use Library like Glide and Picasso for load image in imageview as a string Please check below link How to load Image into ImageView from Url using Glide v4.0.0RC1

Sumit Kumar
  • 263
  • 1
  • 6
0

If you want to store the whole image in your JSON, than you could use base64 to convert from byte[] to String and vice versa. Java has base64 encoders and decoders in it's util packages. Wiki page: https://en.wikipedia.org/wiki/Base64.

AlexAlbu
  • 76
  • 3