Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send image as json entry android

I have a requirement where, i am sending a json file to the server and the parsing happens at the server side. I have created the entries to the json file, now i want to store an image stored in imageview as an entry to the json file. Searched several previous posts but could not find exactly what to do. Any pointers would be of great help for storing the image in json format for sending through server.

like image 273
bharath Avatar asked Jul 04 '26 08:07

bharath


1 Answers

If you want to include Image in a JSON object which you will be sending in a request, convert Image into Base64 string and put this string into the JSON object.

For example:

String encodedImage = Base64.encodeToString(byteArrayImage, Base64.DEFAULT);

Check:

  • How to convert a image into Base64 string?
  • Convert png or jpg image to Base64 string in Android
like image 77
Paresh Mayani Avatar answered Jul 07 '26 09:07

Paresh Mayani



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!