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
11
votes
1 answer

How to change field name in serializers in django

I have a field country_id and country_name and i want to change the name for both fields in Django rest Framework write now I'm getting this data { "data": [ { "country_id": 1, "country_name": "Afghanistan" }, { …
Harman
  • 1,703
  • 5
  • 22
  • 40
11
votes
1 answer

Configuring the .NET WCF UTF-8 deserializer to modify/discard non-shortest form chars instead of throwing an exception?

We have a SOAP web service hosted via WCF. One of the clients we receive data from occasionally encodes UTF-8 using non-shortest form (See http://www.unicode.org/versions/corrigendum1.html for a bit of info on this). It's not easy to modify the…
Redwood
  • 66,744
  • 41
  • 126
  • 187
11
votes
3 answers

How do I deserialize into trait, not a concrete type?

I'm trying to do struct serialization, in which the bytes would eventually be sent down a pipe, reconstructed and methods be called on them. I created a trait these structs would implement as appropriate and I'm using serde and serde-cbor for…
Dash83
  • 1,357
  • 2
  • 17
  • 31
11
votes
2 answers

Scalatest and Spark giving "java.io.NotSerializableException: org.scalatest.Assertions$AssertionsHelper"

I’m testing a Spark Streaming application with the help of "com.holdenkarau.spark-testing-base" and scalatest. import com.holdenkarau.spark.testing.StreamingSuiteBase import org.apache.spark.rdd.RDD import org.scalatest.{ BeforeAndAfter, FunSuite…
Tushar Sudake
  • 1,148
  • 1
  • 14
  • 25
11
votes
1 answer

QuerySet is not JSON Serializable Django

newbie programming here. I have a model with many rows and I would like to pass each row to javascript. First attempt: Views.py events = Events.objects.filter(user_id=user_id) // filter by user_id context = { "email":…
anderish
  • 1,709
  • 6
  • 25
  • 58
11
votes
3 answers

Cannot preserve reference to array or readonly list, or list created from a non-default constructor

I came across the below question which is mostly identical to the issue I am having: JSON.NET cannot handle simple array deserialization? However, my situation is slightly different. If I modify the Test class from that question to have an array…
oscilatingcretin
  • 10,457
  • 39
  • 119
  • 206
11
votes
2 answers

javascript: how to serialize form data to string without jquery or other libraries

how to post form data in ajax way and without jquery or other libraries. I want to define a ajaxForm function, which could serialize the form data and AJAX post, and then callback by javascript. If I has form below:
guilin 桂林
  • 17,050
  • 29
  • 92
  • 146
11
votes
2 answers

Django-Rest-Framework: Paginate nested object

I have two models: class Book(models.Model): title = models.CharField(max_length=250) author = models.CharField(max_length=250) class WordInBook(models.Model): book = models.ForeignKey("Book") word = models.ForeignKey("Word") And…
11
votes
2 answers

Could ByteBuffer implement DataOutput/DataInput?

Is there some subtle reason why java.nio.ByteBuffer does not implement java.io.DataOutput or java.io.DataInput, or did the authors just not choose to do this? It would seem straightforward to map the calls (e.g. putInt() -> writeInt()). The basic…
Justin
  • 4,437
  • 6
  • 32
  • 52
11
votes
3 answers

How to skip Optional.empty fields during Jackson serialization?

I have a Java class with an Optional field. I am serializing the class to JSON using Jackson 2.8.3 (called from Spring web 4.3.3). I am hoping to get the serializer to skip the field if the Optional is empty, and serialize the contained string if it…
André Risnes
  • 137
  • 1
  • 1
  • 8
11
votes
3 answers

Binary fields encoding/serialization format in a proprietary XML file (Roche LC480 .ixo file)

I recently received an example export file generated by the Roche LightCycler 480 instrument. It uses a proprietary XML format, for which I haven't found a specification yet. From such types of files, I would like to extract some information…
Alex
  • 13,024
  • 33
  • 62
11
votes
2 answers

Does C# have a library for parsing multi-level cascading JSON?

Is there a library (C# preferred) to resolve what I would call multi-level cascading JSON? Here is an example of what I mean: (Pseudocode/C#) var json1 = @"{ ""firstName"": ""John"", ""lastName"": ""Smith"" }"; var json2 = @"{ …
W3Max
  • 3,328
  • 5
  • 35
  • 61
11
votes
2 answers

Send and receive serialize object on UDP

I am trying to send a serialized object from a server process to a client process in Java using UDP. The problem is that the client is being blocked on the receive method. Can someone help?! here is the server code for sending the object: …
Noor
  • 19,638
  • 38
  • 136
  • 254
11
votes
3 answers

newtonsoft json serialize timespan format

Is it possible to specify custom format for TimeSpan serialization? Using Newtonsoft.Json. I would like to have serialized string in format HH:mm, so for example: TimeSpan.FromHours(5) -> // "+05:00" TimeSpan.FromHours(-5) -> // "-05:00" Thanks!
Mikhail
  • 978
  • 2
  • 13
  • 28
11
votes
3 answers

How to validate an object before deserializing

In my code, I am calling getObject() method from an ObjectMessage object received from a JMS queue. Fortify report is complaining about this getObject() method with an error name like this Dynamic Code Evaluation: Unsafe Deserialization. Basically…
Tech Noob
  • 510
  • 1
  • 9
  • 33