Skip to main content

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
Filter by
Sorted by
Tagged with
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 ...
Amir Rachum's user avatar
  • 78.5k
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?
live2dream95's user avatar
  • 5,987
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?
user avatar
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 ...
Roman's user avatar
  • 129k
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...
Ritwik Bose's user avatar
  • 6,059
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 ...
Paul Blundell's user avatar
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 ...
Jon Mitchell's user avatar
  • 3,389
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.
leora's user avatar
  • 194k
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. ...
Emma Leis's user avatar
  • 2,900
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 ...
Alpha Hydrae's user avatar
  • 2,941
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&...
DCoder's user avatar
  • 3,438
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>...&...
Sarah Vessels's user avatar
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 ...
Cheeso's user avatar
  • 191k
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 (...
Matt Brindley's user avatar
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 ...
Anders Gustafsson's user avatar
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); ...
AndreaF's user avatar
  • 12.3k
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'...
user1946784's user avatar
  • 1,447
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?
AChoice's user avatar
  • 568
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 ...
TJ-'s user avatar
  • 14.3k
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 ...
ycomp's user avatar
  • 8,516
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 ...
mrip's user avatar
  • 15k
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?...
SRam's user avatar
  • 2,822
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, ...
user avatar
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 ...
xsiand's user avatar
  • 485
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 ...
taz's user avatar
  • 1,526
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 ...
darkbaby123's user avatar
  • 2,025
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?
AngryHacker's user avatar
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 ...
Rajesh Kumar's user avatar
  • 2,503
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 ...
richinrix's user avatar
  • 484
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 ...
Anurag_BEHS's user avatar
  • 1,460
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 ...
lasseeskildsen's user avatar
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 ...
Stephan Jennewein's user avatar
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); ...
Edd's user avatar
  • 8,540
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 ...
Marat's user avatar
  • 6,533
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 ...
Ebbs's user avatar
  • 1,040
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".
Frank's user avatar
  • 2,015
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 ...
Mohamed Emad Hegab's user avatar
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 ...
Brandon's user avatar
  • 6,862
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 ...
Ozymandias's user avatar
  • 2,709
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 ...
kabuko's user avatar
  • 36.2k
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 ...
Blankman's user avatar
  • 264k
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 ?
Rodniko's user avatar
  • 5,056
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 ...
Macarse's user avatar
  • 92.6k
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 ...
Eric's user avatar
  • 2,049
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 [...
Malako's user avatar
  • 535
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 ...
Ismail Addou's user avatar
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 ...
fiacobelli's user avatar
  • 1,980
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?
Brad8118's user avatar
  • 4,692
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 ...
thecoop's user avatar
  • 45.9k

1
2 3 4 5
18