将图像作为json条目发送android

Send image as json entry android(将图像作为json条目发送android)

本文介绍了将图像作为json条目发送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.

解决方案

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

这篇关于将图像作为json条目发送android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:将图像作为json条目发送android

基础教程推荐