Questions tagged [serializable]
Serialization is the process of converting a data structure or object state into a format that can be stored. The `SerializableAttribute` is a .NET Framework attribute that signifies the object is serializable. The `Serializable` Java marker interface indicates that an object can be serialized using standard JVM serialization mechanisms. Other languages and frameworks have similar abstract classes or attributes.
serializable
895
questions
2376
votes
23
answers
816k
views
What is a JavaBean exactly?
I understood, I think, that a "Bean" is a Java-class with properties and getters/setters.
As much as I understand, it is the equivalent of a C struct. Is that true?
Also, is there a real ...
421
votes
16
answers
264k
views
Android: Difference between Parcelable and Serializable?
Why does Android provide 2 interfaces for serializing objects? Do Serializable objects interopt with Android Binder and AIDL files?
294
votes
12
answers
131k
views
What is the difference between Serializable and Externalizable in Java?
What is the difference between Serializable and Externalizable in Java?
250
votes
5
answers
286k
views
What does it mean: The serializable class does not declare a static final serialVersionUID field? [duplicate]
I have the warning message given in the title. I would like to understand and remove it. I found already some answers on this question but I do not understand these answers because of an overload with ...
171
votes
13
answers
133k
views
What does Serializable mean? [duplicate]
What exactly does it mean for a class to be Serializable in Java? Or in general, for that matter...
80
votes
8
answers
96k
views
Android ArrayList of custom objects - Save to SharedPreferences - Serializable?
I have an ArrayList of an object. The object contains the types 'Bitmap' and 'String' and then just getters and setters for both. First of all is Bitmap serializable?
How would I go about serializing ...
80
votes
5
answers
15k
views
Why does HttpServlet implement Serializable?
In my understanding of Servlet, the Servlet will be instantiated by the Container, its init() method will be called once, and the servlet will live like a singleton until the JVM shuts down.
I do not ...
76
votes
4
answers
73k
views
Serializing private member data
I'm trying to serialize an object to XML that has a number of properties, some of which are readonly.
public Guid Id { get; private set; }
I have marked the class [Serializable] and I have ...
60
votes
4
answers
48k
views
What is the point of the ISerializable interface?
It seems like I can serialize classes that don't have that interface, so I am unclear on its purpose.
59
votes
5
answers
50k
views
Do Hibernate table classes need to be Serializable?
I have inherited a Websphere Portal project that uses Hibernate 3.0 to connect to a SQL Server database.
There are about 130 Hibernate table classes in this project. They all implement Serializable. ...
57
votes
4
answers
15k
views
Is using Serializable in Android bad?
I've been reading a lot of posts and articles extolling the speed of Parcelable over Serializable. I've been using both for a while to pass data between Activities through Intents, and have yet to ...
55
votes
3
answers
143k
views
How to pass ArrayList<CustomeObject> from one activity to another? [duplicate]
I want to send Following ArrayList from one activity to another please help.
ContactBean m_objUserDetails = new ContactBean();
ArrayList<ContactBean> ContactLis = new ArrayList<ContactBean&...
50
votes
1
answer
40k
views
using XmlArrayItem attribute without XmlArray on Serializable C# class
I want XML in the following format:
<configuration><!-- Only one configuration node -->
<logging>...</logging><!-- Only one logging node -->
<credentials>...&...
50
votes
5
answers
9k
views
Why should I always make my Exceptions [serializable]? (.NET)
Referring to What is the correct way to make a custom .NET Exception serializable?
and Are all .NET Exceptions serializable? ...
Why should my exceptions be serializable?
Someone said "it can be ...
45
votes
5
answers
17k
views
How can I add a type constraint to include anything serializable in a generic method?
My generic method needs to serialize the object passed to it, however just insisting that it implements ISerializable doesn't seem to work. For example, I have a struct returned from a web service (...
43
votes
3
answers
28k
views
Portable class library: recommended replacement for [Serializable]
I am porting a .NET Framework C# class library to a Portable Class Library. One recurring problem is how to deal with classes decorated with the [Serializable] attribute, since this attribute is not ...
42
votes
5
answers
65k
views
Cannot pass custom Object in an Intent: The Method Put Extra is Ambiguous for the type Intent
If I try to write
Car myCarObject=getCar();
Intent details = new Intent(Start.this, DetailsCar.class);
details.putExtra("Car", myCarObject);
startActivity(details);
...
41
votes
13
answers
52k
views
GWT - occasional com.google.gwt.user.client.rpc.SerializationException
we are haunted by occasional occurences of exceptions such as:
com.google.gwt.user.client.rpc.SerializationException: Type 'xxx' was not assignable to 'com.google.gwt.user.client.rpc.IsSerializable'...
39
votes
5
answers
4k
views
Penalty to implement Serializable in Java?
Is there a penalty to add
implements Serializable
to a Java class? Impact on size of instantiated object or performance?
37
votes
4
answers
27k
views
Why doesn't java.lang.Object implement the Serializable Interface? [duplicate]
Possible Duplicate:
Why Java needs Serializable interface?
According to Serializability in Java docs :
Serializability of a class is enabled by the class implementing the
java.io.Serializable ...
37
votes
6
answers
19k
views
If my class implements Serializable, do I have to implement it in its subclasses?
If I have B extends A... and A implements Serializable, do I have to write "B implements Serializable" ?
I think no, but I would like confirmation...
also if I put serialization id in A... do I need ...
35
votes
2
answers
3k
views
Getting rid of the comment above Eclipse-generated serialVersionUID
This has become a pet peeve of mine. I write a class, and implement Serializible. Then eclipse warns me that I don't have a serialVersionUID, so I select "Add generated serialVersionUID" or "Add ...
34
votes
5
answers
18k
views
what is difference between Parcelable and Serialization used in android
I want to know exact ,
whether should I used parcelable or serialization technique
for sending data from one activity to other?
is it compulsory to
use one of them for sending data from one to other?...
33
votes
4
answers
54k
views
Python serializable objects json [duplicate]
class gpagelet:
"""
Holds 1) the pagelet xpath, which is a string
2) the list of pagelet shingles, list
"""
def __init__(self, parent):
if not isinstance( parent, ...
32
votes
6
answers
30k
views
Use parcelable to store item as sharedpreferences?
I have a couple objects, Location, in my app stored in an ArrayList and use parcelable to move these between activities. The code for the object looks like this:
public class Location implements ...
30
votes
8
answers
57k
views
What is the difference between "conflict serializable" and "conflict equivalent"?
In database theory, what is the difference between "conflict serializable" and "conflict equivalent"?
My textbook has a section on conflict serializable but glosses over conflict equivalence. These ...
30
votes
2
answers
10k
views
Why does PostgreSQL serializable transaction think this as conflict?
In my understanding PostgreSQL use some kind of monitors to guess if there's a conflict in serializable isolation level. Many examples are about modifying same resource in concurrent transaction, and ...
29
votes
2
answers
4k
views
Does adding [Serializable] to the class have any performance implications?
I need to add the [Serializable] attribute to a class that is extremely performance sensitive.
Will this attribute have any performance implications on the operation of the class?
28
votes
2
answers
20k
views
Can I use DataContract and Serializable together?
I am working on WCF service. My all class are already serialize using [Serializable] attribute but due to "k__BackingField" Property Naming problem I used DataContract and DataMember attribute.
so ...
25
votes
6
answers
21k
views
Reason: `object` ("[object Date]") cannot be serialized as JSON. Please only return JSON serializable data types
I am using Prisma and Next.js. When I try to retrieve the content from Prisma in getStaticProps it does fetch the data but I can't pass it on to the main component.
export const getStaticProps = async ...
24
votes
7
answers
2k
views
Use of Serializable other than Writing& Reading object to/from File
In Which Cases it is a good coding practice to use implements serializable other than Writing & Reading object to/from file.In a project i went through code. A class using implements serializable ...
23
votes
5
answers
6k
views
Persist an object that is not marked as serializable
I need to persist an object that is not marked with the serializable attribute. The object is from a 3rd party library which I cannot change.
I need to store it in a persist place, like for example ...
22
votes
4
answers
13k
views
Serialization of a class with events
I have a Class like this:
public delegate void ChangedEventHandler(object sender, EventArgs e);
[Serializable]
public class valueDouble
{
public event ChangedEventHandler Changed;
public ...
22
votes
1
answer
31k
views
File extension for a Serialized object
What file extension would be most suitable when saving a Serializable object to disk?
FileOutputStream fos = null;
ObjectOutputStream out = null;
try {
fos = new FileOutputStream(filename);
...
22
votes
4
answers
13k
views
Android 13 (SDK 33): Bundle.getSerializable(String) is deprecated, what is alternative?
Starting from API level 33 the getSerializable(String) method of Bundle class is deprecated. Documentation suggests to use getSerializable(String, Class) instead. But that function is only available ...
19
votes
1
answer
11k
views
Using Serializable attribute on Model in WebAPI
I have the following scenario: I am using WebAPI and returning JSON results to the consumer based on a model. I now have the additional requirement to serialize the models to base64 to be able to ...
19
votes
8
answers
10k
views
What is a serializable object?
What is a serializable object in C#?
I guess the word serializable is throwing me off more than "serializable object".
18
votes
1
answer
10k
views
undefined method `serializable_hash' for String
i'm trying to_json in the following way
@own_events.as_json(:include => {:created_date => {},:attendees => {}, :user => {}, :start_times => {}, :end_times =>{}} )
and ...
18
votes
5
answers
12k
views
Does Java Serialization work for cyclic references?
For example: Object A contains Object B that contains Object C that contains Object A.
Will Object A serialize properly?
Comment #9 here indicates that it does not work .
In contrast, XStream ...
18
votes
1
answer
9k
views
Visual Studio Code Java: Disable serialVersionUID warning
I'm taking a Computer Science class where the assignment boilerplate code is a Java framework where most of the classes (or their superclasses) extend Serializable. What ends up happening then is ...
17
votes
2
answers
13k
views
How to stop ProGuard from stripping the Serializable interface from a class
Is there an explicit way to stop ProGuard from changing a class from implementing an interface?
I have a class that implements java.io.Serializable, let's call it com.my.package.name.Foo. I've found ...
17
votes
6
answers
14k
views
Why do you have to mark a class with the attribute [serializable]?
Seeing as you can convert any document to a byte array and save it to disk, and then rebuild the file to its original form (as long as you have meta data for its filename etc.).
Why do you have to ...
16
votes
1
answer
32k
views
Difference between using XMLRoot/XMLElement and using Serializable() attributes (in c#)
what is Difference between using XMLRoot/XMLElement and using Serializable() attributes?
how do i know when to use each ?
16
votes
6
answers
15k
views
Who actually implements serializable methods?
I've been learning how to use Serializable.
I know if I create a class 'A' with different variables who implements Serializable and I add Serializable to my class, it's also Serializable.
But, who ...
16
votes
3
answers
4k
views
When using ISerializable with DataContractSerializer, how do I stop the serializer from outputting type information?
To get more control over serialization, I have converted a class from [DataContract] to [Serializable], implementing both GetObjectData and the special deserializing constructor. When I do this, the ...
15
votes
1
answer
9k
views
ASP.NET Web API and [Serializable] class
I have a class that is marked with [Serializable]. When i return it from the Web API the field names are all funky.
Normally the JSON returned is
[{"OrderId":797 ...
JSON returned when using [...
15
votes
1
answer
48k
views
how to send/receive Objects using sockets in java [duplicate]
When I execute my code in the CMD window, it doesn't work in Client mode, exactly at the line:
ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
ObjectOutputStream oos = new ...
15
votes
2
answers
3k
views
Serializable, cloneable and memory use in Java
I am using an inner class that is a subclass of a HashMap. I have a String as the key and double[] as the values. I store about 200 doubles per double[]. I should be using around 700 MB to store ...
14
votes
3
answers
10k
views
Why should I not make a class Serializable?
I'm storing some objects in my viewstate and I was wondering if there are any disadvantages to making a class Serializable?
Is it bad practice to make all of the classes Serializable?
14
votes
1
answer
3k
views
What's the best way of ensuring a Function argument is serializable?
I'm writing a serializable class that takes several arguments, including a Function:
public class Cls implements Serializable {
private final Collection<String> _coll;
private final ...