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
11k 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
42 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
514 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
607 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
804 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
625 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
601 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
620 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
383 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
152 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
417 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
85 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
206 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
358 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
117 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
703 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
309 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
134 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
263 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
532 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
6k 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
357 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
83 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
447 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
12k 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
144 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
428 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
214 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
973 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
1k 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
184 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
126 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
92 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
2k 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
502 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
173 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
197 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
181 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
29k 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 ...
6
votes
4answers
7k views

Hex encoding and decoding of ASCII strings in VBA

I needed to convert some Ascii text to binary in Hex format 0x00FF.... I've written an EncodeHex and a ...
1
vote
1answer
90 views

Translating binary data from a file into a very large base-ten integer

I'm making an experimental Java algorithm that translates binary data from a file into a (very large) base ten integer. I am using BigInteger since this number may ...
4
votes
1answer
95 views

Serializing Objects to Delimited Files Part II

This is a follow up to my previous question: Serializing objects to delimited files I've added some feature enhancements, and based on suggestions from rolfl in chat, I've fixed up a couple ...
4
votes
1answer
2k views

A from_string() function (inverse of std::to_string)

I've been thinking of using this: ...
2
votes
0answers
215 views

Library for manipulation of binary protocol headers

I'm starting with implementing a TCP/IP stack for embedded systems which will be done in C++ and I've found I need a good way to work with protocol headers involved (e.g. ARP, IP, TCP). Major ...
11
votes
3answers
4k views

Structure to ByteArray Extension

I have a need to turn various structures into byte arrays to be sent over serial port to another machine. I created generic extensions to turn any structure into a byte array and from a byte array ...
5
votes
2answers
103 views

Parsing shorts from binary file and finding the closest and furthest points

A few months ago I got rejected at the technical interview for a position. The problem that they gave me is the following: From a binary file, parse two shorts, x and y and build a Point object with ...