Questions tagged [serialization]

Serialization is the process by which data-structures are converted into a format that can be easily stored or transmitted and subsequently reconstructed.

Serialization is the process of converting a or object's state into a format that can be stored (for example, in a flat file or memory ) or transmitted over a network, to be reconstructed later maintaining data integrity - typically in a different run-time environment which may or may not be on the same computer.

The process of serializing an object is sometimes referred to as - however depending on the context / language this term may take on a slightly different meaning. The process of reconstructing a data structure from its serialized form is known as .

Popular formats for serialization are and .

33160 questions
3395
votes
25 answers

What is a serialVersionUID and why should I use it?

Eclipse issues warnings when a serialVersionUID is missing. The serializable class Foo does not declare a static final serialVersionUID field of type long What is serialVersionUID and why is it important? Please show an example where missing…
ashokgelal
  • 80,002
  • 26
  • 71
  • 84
2044
votes
40 answers

How can I display a JavaScript object?

How do I display the content of a JavaScript object in a string format like when we alert a variable? The same formatted way I want to display an object.
maxjackie
  • 22,386
  • 6
  • 29
  • 37
1758
votes
58 answers

Convert form data to JavaScript object with jQuery

How do I convert all elements of my form to a JavaScript object? I'd like to have some way of automatically building a JavaScript object from my form, without having to loop over each element. I do not want a string, as returned by…
Yisroel
  • 8,164
  • 4
  • 26
  • 26
1336
votes
43 answers

How to make a class JSON serializable

How to make a Python class serializable? class FileItem: def __init__(self, fname): self.fname = fname Attempt to serialize to JSON: >>> import json >>> x = FileItem('/foo/bar') >>> json.dumps(x) TypeError: Object of type 'FileItem' is…
Sergey
  • 19,487
  • 13
  • 44
  • 68
1233
votes
11 answers

Serializing to JSON in jQuery

I need to serialize an object to JSON. I'm using jQuery. Is there a "standard" way to do this? My specific situation: I have an array defined as shown below: var countries = new Array(); countries[0] = 'ga'; countries[1] = 'cd'; ... and I need to…
Herb Caudill
  • 50,043
  • 39
  • 124
  • 173
1224
votes
15 answers

How do I turn a C# object into a JSON string in .NET?

I have classes like these: class MyDate { int year, month, day; } class Lad { string firstName; string lastName; MyDate dateOfBirth; } And I would like to turn a Lad object into a JSON string like this: { …
Hui
  • 13,887
  • 8
  • 25
  • 20
1192
votes
42 answers

Converting an object to a string

How can I convert a JavaScript object into a string? Example: var o = {a:1, b:2} console.log(o) console.log('Item: ' + o) Output: Object { a=1, b=2} // very nice readable output :) Item: [object Object] // no idea what's inside :(
user680174
  • 11,921
  • 3
  • 15
  • 3
1176
votes
32 answers

Deserialize JSON into C# dynamic object?

Is there a way to deserialize JSON content into a C# dynamic type? It would be nice to skip creating a bunch of classes in order to use the DataContractJsonSerializer.
jswanson
  • 16,244
  • 6
  • 20
  • 15
701
votes
13 answers

What is the difference between Serialization and Marshaling?

I know that in terms of several distributed techniques (such as RPC), the term "Marshaling" is used but don't understand how it differs from Serialization. Aren't they both transforming objects into series of bits? Related: What is…
Peter
  • 47,963
  • 46
  • 132
  • 181
687
votes
10 answers

How do you do a deep copy of an object in .NET?

I want a true deep copy. In Java, this was easy, but how do you do it in C#?
user18931
  • 10,715
  • 9
  • 28
  • 21
656
votes
20 answers

Preferred method to store PHP arrays (json_encode vs serialize)

I need to store a multi-dimensional associative array of data in a flat file for caching purposes. I might occasionally come across the need to convert it to JSON for use in my web app but the vast majority of the time I will be using the array…
KyleFarris
  • 17,274
  • 5
  • 40
  • 40
612
votes
27 answers

JSON.NET Error Self referencing loop detected for type

I tried to serialize POCO class that was automatically generated from Entity Data Model .edmx and when I used JsonConvert.SerializeObject I got the following error: Error Self referencing loop detected for type System.data.entity occurs. How do…
NevenHuynh
  • 6,589
  • 5
  • 22
  • 25
534
votes
16 answers

How to Deserialize XML document

How do I Deserialize this XML document: 1020 Nissan Sentra 1010
Alex
  • 39,265
  • 21
  • 45
  • 42
519
votes
4 answers

How can I change property names when serializing with Json.net?

I have some data in a C# DataSet object. I can serialize it right now using a Json.net converter like this DataSet data = new DataSet(); // do some work here to populate 'data' string output = JsonConvert.SerializeObject(data); However, this uses…
culix
  • 10,188
  • 6
  • 36
  • 52
481
votes
7 answers

Understanding passport serialize deserialize

How would you explain the workflow of Passport's serialize and deserialize methods to a layman. Where does user.id go after passport.serializeUser has been called? We are calling passport.deserializeUser right after it where does it fit in the…
Anubhav
  • 7,138
  • 5
  • 21
  • 33
1
2 3
99 100