Is it possible to attach file to JSONObject in Java (and to JSON at all)?
For example, can I attach bitmap to 'image' field?
{'user_id':'5', 'auth_token':'abc', 'image': ???}
You can convert the bitmap (or any binary data) to text using base64 (which makes it a String) I wouldn't use one of the Base64 classes in the JVM unless you are fully aware that they are for internal use. (may not be available on all JDKs and could change in future versions)
You could copy java.util.prefs.Base64 if you don't have one in a library already.
refer the answer of BalusC
A bitmap is binary data. JSON is to be represented as character data. So you need to convert binary data to character data and vice versa without loss of information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With