Questions tagged [serialization]

Serialization is the process by which an object is converted into a format that can be stored and later retrieved.

Filter by
Sorted by
Tagged with
4
votes
1answer
137 views

C++ string Formatter Again Part-3

Previously asked here. The code is now available on GitHub. Since the previous review I have added unit tests. Since it is big it will come in a couple of parts. Part 1 | Part 2 | Part 3 | Part 4 ...
4
votes
1answer
115 views

C++ string Formatter Again Part-2

Previously asked here. The code is now available on GitHub. Since the previous review I have added unit tests. Since it is big it will come in a couple of parts. Part 1 | Part 2 | Part 3 | Part 4 Part ...
5
votes
2answers
196 views

C++ string Formatter Again Part-1

Previously asked here. The code is now available on GitHub. Since the previous review I have added unit tests. Since it is big it will come in a couple of parts. Part 1 | Part 2 | Part 3 | Part 4 Part ...
13
votes
6answers
7k views

Calculate fingerprint for an object

I need to store serialized objects in a database and I want to avoid duplicates. In order to be able to tell wheter an object is already stored, I have to compare them somehow. My idea was to ...
3
votes
1answer
390 views

HL7 message builder and unit tests

I had to code a project due to my final exams in April. It is an application which simulates a hospital. There are admissions, transfers and discharges of patients in this hospital. For each of those,...
4
votes
0answers
106 views

(de-)serializer for arbitrary python objects

My program is intended to allow (de-)serialization of arbitrary Python objects. It's basically a replacement for python's pickle module, which is similar but prone ...
3
votes
1answer
423 views

Base64 string ↔ float array

I need to convert f32 arrays with a fix length to base64 representation and back. My current code looks like this. It works, but it feels way too complicated. How ...
7
votes
1answer
14k views

Workaround for unchecked cast of a deserialized Object to ArrayList<Vehicle>

For a class I was assigned to write code to read objects of the class Vehicle using ObjectInputStream (in). The objects are ...
1
vote
0answers
49 views

Class that pickles, unpickles and extends pickled documents

I've been pickling ngram models and I wrote this class to be able to easily extend models when training. I wanted to know if it could possibly be done in a better way? ...
6
votes
2answers
578 views

Variable integer encoding

There is a varint encoding, which I call LEP64 (Little Endian Prefix Max 64-bit). Basically, the first byte of the encoded value tells us, how many bytes follow (needed bytes encoded in unary coding, ...
6
votes
1answer
681 views

Python read/write pickled file

Is there a way in Python 2.7 to improve reading/writing speed (or memory consumption of the file) compared to this version? ...
2
votes
1answer
1k views

Overriding properties at runtime but not for serialization

I have a use case where I need to deserialize some settings from a JSON file and override their values at runtime but when then configuration is saved, I want to keep the original value. Imagine a ...
0
votes
1answer
815 views

Golang visitor pattern for marshaling shapes as JSON, and XML

I was trying to implement visitor pattern in Golang, and came across an idea of using a generic func type instead if interface ...
3
votes
0answers
676 views

Implementing a JSON-serializable ORM model

I implemented a library which, amongst other things, implements a JSON-serializable ORM model based on the peewee framework. Here's the relevant excerpt: ...
3
votes
2answers
677 views

Serializing a class hierarchy to JSON

I have a hierarchical object structure which needs to be converted to JSON. I have a following basic implementation of how it will be done: ...
1
vote
0answers
442 views

Save protobuf-net serialized data with variable length to a file

My program gets continuously raw input from a stream (TCP), then process the data and output the data to a graph. It should also save the data to a file so it can be read afterwards. To archive this I ...
6
votes
2answers
194 views

Save a playlist to file in a relatively safe fashion

I am writing a music player in Java / JavaFX. The player allows the user to create playlists (which are a list of songs). These user-created playlists are displayed in the music player's library. ...
2
votes
2answers
519 views

Compare two files and save the result into a pickle file

My code should compare two vectors saved as dictionary (two pickle files) and save the result into a pickle file too. This works but very slowly. For one compare result I'm waiting about 7:20 min. ...
2
votes
1answer
109 views

Marshaling to a complex structure in .net

This is a follow up from question https://stackoverflow.com/questions/45106245/net-file-random-access-recoard-locking I have been able to make the reading and marshalling work ok but the performance ...
3
votes
1answer
321 views

Exporting an object to a ZIP file

I have my own type of object, which implements Serializable. Here I have one called "extendedFormat" (not a terribly helpful name, yes, I know). I'm writing it out ...
2
votes
1answer
515 views

Transform byte array into upside down array of floating point pixels

I need to do the following in Python 3.x: Interpret an array of bytes as an array of single-precision floats. Then group each four consecutive floats into subarrays, i.e. transform ...
3
votes
0answers
130 views

Trait class for a serialization framework

In a current project I have implemented a small non-intrusive serialization framework based on type traits. The generic trait template looks like this: ...
7
votes
1answer
998 views

Python 3.x Hexdump

I posted a small hexdump generator function from a program I've been writing not long ago and applied what a reviewer suggested since then. The goal was to lazily hexdump bytes objects (byte strings, ...
1
vote
1answer
425 views

Extract list of selected contractors by matching serialized array in Rails

I'm working on an application where I have a Company model setup as follows: ...
6
votes
2answers
138 views

GameServer SocketListener + PlayerManagement

Today I was posting a question to get a bit of information on how to optimize my code for maximum performance. I'm a beginner to C# (in a sense) and I don't really know as much as all of you other ...
2
votes
1answer
392 views

Using serializable to preserve/save objects

I'm building one of my first android apps. I met this problem that everytime you change screen orientation, Android destroys the app and builds it up again (I know this is more complex, but this isn't ...
2
votes
2answers
39 views

Serializing types with a common superclass

I have written code responsible for saving data to a file using Serialization. I think that a natural way to avoid repetition is to use inheritance but I'm not sure ...
1
vote
1answer
616 views

F# binary reader

I've written a fairly simple script in F# which reads structured data from binary. I've avoided using the built-in .NET BinaryReader class because it's stateful in that it maintains its index in the ...
8
votes
3answers
7k views

Save and load the state of a role-playing game using Pickle

I am working on a text-based adventure game and I'm implementing new features, one of these features being saves and loads. This code works, and I know that there is a more efficient way of coding it, ...
4
votes
1answer
392 views

Three methods to serialize 7-, 6-, and 3-dimensional int arrays

Here's some code I wrote which sends multi-dimensional arrays to a file, is there any way I can make a generic method? ...
3
votes
1answer
87 views

Conversion of Haskell CBOR decoding code into Rust

I was interested in converting the following Haskell code, that does decoding of CBOR into Rust: ...
2
votes
1answer
509 views

Replacing DataContract serialization with Binary one in Azure Service Fabric

Azure Service Fabric uses DataContract serialization, which is a total disaster – it violates LSP (wiki) - see all those ...
8
votes
2answers
16k views

Converting std::chrono::time_point to/from std::string

Consider these functions that allow to convert std::chrono::time_point to/from std::string with a predefined date-time format. <...
4
votes
1answer
1k views

Parsing GSM 7-Bit messages in Java

I wrote a function to decode GSM 7-Bit encoded messages as defined in the 3GPP standard. Example available here. I found a tool to help me check my answers here. I used the charset from here. ...
4
votes
2answers
166 views

Simple directory and file serialization protocol for Python 2 and 3

The first edition of this code was written back when Python 2 had not yet been deprecated in favor of Python 3. The difference between strings and bytes were not very clear back then. Also, PEP8 ...
8
votes
2answers
467 views

Sending data to a database in size-limited chunks

I have a method which takes a parameter which is Partition enum. This method will be called by multiple background threads around same time period by passing ...
2
votes
1answer
232 views

Serialize and deserialize binary tree with a lot of empty nodes

Here is my code to serialize and deserialize binary tree, which may have a lot of empty nodes. I am written in Python 2.7. Any advice on performance improvement in terms of algorithm time complexity, ...
0
votes
1answer
1k views

Serialize all the fields into one byte array and deserialize byte array into individual fields

I have a class in which I am passing certain parameters through the constructor and then using those parameters to make one final byte array with a proper format (header + data) and it works fine: <...
1
vote
1answer
2k views

Serialize data into one byte array using ByteBuffer

I have a class in which I am passing certain parameters through the constructor and then using those parameters to make one final byte array with a proper format (header + data): ...
4
votes
3answers
191 views

Setting Entity Framework up for success

So I am working on an application (top-secret!) that I need settings for, these settings are pretty basic, but I don't want to make a single-row table with a bunch of serialized settings, or a single-...
3
votes
1answer
145 views

Reading a string-to-string map from an archive

I have a CArchive Which contains a serialized CMapStringToString. From my research it is my understanding that it is quite ...
1
vote
4answers
93 views

Creating enchantment objects based on configuration

I'm searching a way to literally shorten my code. For the moment my code is this; ...
2
votes
2answers
3k views

Serialize and deserialize binary tree

Here is my code of serialize and de-serialize a binary tree, looking for advice. One issue in my mind which I cannot resolve is, I am using a global variable index, wondering if more elegant solutions ...
3
votes
2answers
547 views

ConcurrentDictionary, Store Key and Compression

So i have a ConcurrentDictionary<int, string> The "int" is merely the way i store the key, which i want more recommendations on. Currently i do like this. ...
4
votes
1answer
4k views

Converting HEX values to Unicode characters

I have a small bot for social network, which accepts message "unicode XXXX XXXX XXXX ...", where XXXX - HEX values which I ...
3
votes
1answer
1k views

Serialize and deserialize a tree

Suppose each node of a tree has maximum n children. I want to serialize and de-serialize for a tree. My current solution is doing pre-order traverse, and using <...
3
votes
1answer
213 views

Python date compression

I m making a script to store date information in the smallest size in bits (I don't mind of the actually memory use in the program / runtime) ...
-1
votes
1answer
207 views

Construct: (un)dumping bytes to hex

This code is part of the Construct library. Docstrings explain what the code is supposed to do. ...
1
vote
0answers
216 views

A tiny library that implements bencoding (simple data encoding format)

Here are three files that make my library that implements a quite simple data encoding. What improvements would you suggest? README.md ...
6
votes
1answer
33k views

Converting a bytearray into an integer

I am working on a program to decode MMS PDU files. They are binary files and I am reading them byte by byte and decoding each header value as I come to it. One header value is the Date, and it's ...