Is it possible to send a file using JSON

Is it possible to connect a file to a JSONObject in Java (and to JSON in general)?

For example, is it possible to snap a bitmap image to the image field?

{'user_id':'5', 'auth_token':'abc', 'image': ???} 
+8
java json
source share
3 answers

You can convert the bitmap (or any binary data) to text using base64 (which makes it a string). I would not use one of the Base64 classes in the JVM if you are not fully aware that they are intended for internal use. (may not be available for all JDKs and may change in future versions)

You can copy the java.util.prefs.Base64 file if you do not already have it in the library.

+8
source share

We send the answer BalusC

A bitmap is binary data. JSON should be represented as character data. Therefore, you need to convert binary data to character data and vice versa without losing information.

+4
source share

Yes, you can send an image by converting this image to character data,

+2
source share

All Articles