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.

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. Other languages and frameworks have similar abstract classes or attributes.

The Serializable Java marker interface indicates that an object can be serialized using standard JVM serialization mechanisms.

Other uses of this tag should probably use .

854 questions
20
votes
1 answer

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); out = new ObjectOutputStream(fos); …
Edd
  • 7,660
  • 14
  • 44
  • 70
19
votes
8 answers

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
  • 1,985
  • 9
  • 35
  • 57
18
votes
1 answer

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 VSCode complains to me that The serializable class…
AjaxLeung
  • 1,588
  • 17
  • 24
18
votes
2 answers

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 serializable transaction works great. But I want…
darkbaby123
  • 1,705
  • 15
  • 15
16
votes
6 answers

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 is actually implementing those two methods to…
Macarse
  • 87,001
  • 42
  • 169
  • 229
16
votes
6 answers

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 mark a class with [Serializable] etc? Is that just…
Blankman
  • 236,778
  • 296
  • 715
  • 1,125
16
votes
4 answers

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 indicates that it does handle cyclic references.
Brandon
  • 6,652
  • 11
  • 34
  • 49
15
votes
2 answers

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 the keys, the pointers and the doubles. However,…
fiacobelli
  • 1,912
  • 4
  • 22
  • 30
15
votes
1 answer

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
  • 4,280
  • 15
  • 62
  • 89
15
votes
1 answer

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 persist them in cache and/or use them for auditing…
Ebbs
  • 970
  • 2
  • 17
  • 37
15
votes
1 answer

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 created_date is a method like that def created_date …
Mohamed Emad Hegab
  • 2,597
  • 6
  • 37
  • 64
15
votes
2 answers

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 that after running through ProGuard, it no longer…
kabuko
  • 35,009
  • 7
  • 75
  • 92
13
votes
3 answers

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 XML emitted now has type information applied to…
Eric
  • 1,939
  • 2
  • 25
  • 34
13
votes
3 answers

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
  • 4,494
  • 10
  • 34
  • 48
13
votes
1 answer

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 _coll; private final Function _func; public…
thecoop
  • 42,842
  • 15
  • 122
  • 181
1 2
3
56 57