I would like to know why object exchange between activities is made as Parcelable and why not as a JSON string. I understand Parcelable is better than Serialization. Can anyone make a comparison between Parcelable and JSON.
I would like to know why object exchange between activities is made as Parcelable and why not as a JSON string
Not everything that can go in a Parcel
can go in a JSON string, such as:
IBinder
objects (associated with remote services using AIDL) ParcelFileDescriptor
Exception
Also, while you could convert a byte[]
into a String
(eg, base-64 encoding), that will be inefficient.
Parcelable is very low level. Therefore its much faster then everything else available nowadays on android (like Serializeable). Json wouldn't make no sense regarding performance (think of performance issues while writing and reading json) and memory space.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.