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
224
votes
16 answers

What is Serialization?

I am getting started with Object-Oriented Programming (OOP) and would like to know: what is the meaning of serialization in OOP parlance?
222
votes
12 answers

How to JSON serialize sets?

I have a Python set that contains objects with __hash__ and __eq__ methods in order to make certain no duplicates are included in the collection. I need to json encode this result set, but passing even an empty set to the json.dumps method raises a…
DeaconDesperado
  • 9,977
  • 9
  • 47
  • 77
220
votes
4 answers

Lowercase JSON key names with JSON Marshal in Go

I wish to use the "encoding/json" package to marshal a struct declared in one of the imported packages of my application. Eg.: type T struct { Foo int } Because it is imported, all available (exported) fields in the struct begins with an upper…
ANisus
  • 74,460
  • 29
  • 162
  • 158
215
votes
13 answers

How to serialize a TimeSpan to XML

I am trying to serialize a .NET TimeSpan object to XML and it is not working. A quick google has suggested that while TimeSpan is serializable, the XmlCustomFormatter does not provide methods to convert TimeSpan objects to and from XML. One…
joeldixon66
  • 2,153
  • 2
  • 13
  • 5
211
votes
3 answers

When should we implement Serializable interface?

public class Contact implements Serializable { private String name; private String email; public String getName() { return name; } public void setName(String name) { this.name = name; } public String…
theJava
  • 14,620
  • 45
  • 131
  • 172
206
votes
14 answers

When and why JPA entities should implement the Serializable interface?

The question is in the title. Below I just described some of my thoughts and findings. When I had a very simple domain model (3 tables without any relations), all my entities did NOT implement the Serializable interface. But when the domain model…
Roman
  • 64,384
  • 92
  • 238
  • 332
205
votes
14 answers

Print array to a file

I would like to print an array to a file. I would like the file to look exactly similar like how a code like this looks. print_r ($abc); assuming $abc is an array. Is there any one lines solution for this rather than regular for each look. P.S - I…
Atif
  • 10,623
  • 20
  • 63
  • 96
204
votes
13 answers

JSON.Net Self referencing loop detected

I have a mssql database for my website within 4 tables. When I use this: public static string GetAllEventsForJSON() { using (CyberDBDataContext db = new CyberDBDataContext()) { return JsonConvert.SerializeObject((from a in db.Events…
PassionateDeveloper
  • 14,558
  • 34
  • 107
  • 176
196
votes
25 answers

form serialize javascript (no framework)

Wondering is there a function in javascript without jquery or any framework that allows me to serialize the form and access the serialized version?
RussellHarrower
  • 6,470
  • 21
  • 102
  • 204
195
votes
9 answers

Serialising an Enum member to JSON

How do I serialise a Python Enum member to JSON, so that I can deserialise the resulting JSON back into a Python object? For example, this code: from enum import Enum import json class Status(Enum): success =…
Bilal Syed Hussain
  • 8,664
  • 11
  • 38
  • 44
186
votes
7 answers

Can Json.NET serialize / deserialize to / from a stream?

I have heard that Json.NET is faster than DataContractJsonSerializer, and wanted to give it a try... But I couldn't find any methods on JsonConvert that take a stream rather than a string. For deserializing a file containing JSON on WinPhone, for…
Omri Gazitt
  • 3,428
  • 2
  • 21
  • 27
179
votes
15 answers

How do I PHP-unserialize a jQuery-serialized form?

Using $('#form').serialize(), I was able to send this over to a PHP page. Now how do I unserialize it in PHP? It was serialized in jQuery.
Gene Bean
  • 1,815
  • 2
  • 12
  • 4
174
votes
5 answers

How to serialize a lambda?

How can I elegantly serialize a lambda? For example, the code below throws a NotSerializableException. How can I fix it without creating a SerializableRunnable "dummy" interface? public static void main(String[] args) throws Exception { File…
assylias
  • 321,522
  • 82
  • 660
  • 783
168
votes
8 answers

Is it possible to deserialize XML into List?

Given the following XML: 1 Joe 2 John And the following class: public class User { …
Daniel Schaffer
  • 56,753
  • 31
  • 116
  • 165
167
votes
8 answers

is not JSON serializable

I have the following code for serializing the queryset: def render_to_response(self, context, **response_kwargs): return HttpResponse(json.simplejson.dumps(list(self.get_queryset())), mimetype="application/json") And…
tuna
  • 6,211
  • 11
  • 43
  • 63