发送图像JSON入门安卓 [英] Send image as json entry android
问题描述
我在哪里,我送一个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);
检查:
- 如何将图像转换为Base64的字符串?
- <一个href="http://stackoverflow.com/questions/3531408/convert-png-or-jpg-image-to-base64-string-in-android">Convert PNG或JPG图像的Base64字符串中的Android
- How to convert a image into Base64 string?
- Convert png or jpg image to Base64 string in android
这篇关于发送图像JSON入门安卓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!