发送图像JSON入门安卓 [英] Send image as json entry android

查看:177
本文介绍了发送图像JSON入门安卓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在哪里,我送一个JSON文件到服务器的要求和分析发生在服务器端。我创建的条​​目的JSON文件,现在我要存储存储在ImageView的是一个条目JSON文件的图像。搜索数previous职位,但无法找到该怎么做。任何指针将有很大的帮助,用于存储JSON格式的图像通过服务器发送。

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.

推荐答案

如果您要包含图像,其中你会被发送请求中的JSON对象,转换图片为Base64的字符串,并把这个字符串转换成JSON对象。

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.

例如:

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

检查:

  • How to convert a image into Base64 string?
  • Convert png or jpg image to Base64 string in android

这篇关于发送图像JSON入门安卓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆