Questions tagged [serialization]
Serialization is the process by which an object is converted into a format that can be stored and later retrieved.
266
questions
32
votes
1answer
6k views
JSON Serializer
Carrying on from:
Yet another C++ Json Parser
Yet another C++ Json Parser (Recursive)
All the code is available from git hub: ThorsSerializer but only reviewing a small section here.
The idea is ...
16
votes
6answers
2k views
Avoiding repetition when using the “snprintf idiom” to write text
I'm writing a function to stringify a nested struct. I'm using snprintf to pre-calculate how much space I'll need to allocate.
The problem is, it's extremely ...
14
votes
4answers
418 views
Rolling my own Configuration with UI
The Rubberduck Saga continues as I find a need to roll my own configuration. Since the program is really a *.dll and available to several host applications, using app.config is not an option. I ...
13
votes
6answers
8k 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 ...
12
votes
3answers
5k 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 ...
12
votes
2answers
473 views
Data marshaling wrapper for a TCP server
After a lot of research, I created this wrapper which I think fits very well to my needs. My project is a TCP server and I will be using this wrapper every time the server receives a packet. Basically,...
11
votes
7answers
8k views
Numbers to byte-arrays and back
As the title explains, this is a series of extension methods that convert certain numeric types to and from byte-arrays, for certain actions which work better on byte-array types than numeric types.
...
11
votes
5answers
50k views
Conversion of hexadecimal string to string
Given a C# string which is a set of hexadecimal numbers such as:
string HexString = "202048656c6c6f20576f726c64313233212020";
Where those hexadecimal numbers ...
11
votes
3answers
5k views
Simple Generic output for Deserializer
Lately I have been learning about serialization so I decided to write a little helper class for my application to make it easy to use this feature in multiple places. I actually mixed some generics in ...
11
votes
3answers
2k views
Decoding assembly instructions in a Game Boy disassembler
I am coding a game boy disassembler in C++. The program (simplified here) converts a vector of byte into an assembly instruction and print it.
To do so, it iterates through the vector of bytes (char)...
11
votes
2answers
2k views
NewtonSoft Json.Net serialiser
I'm just starting to develop more in C# after being mainly a VB.NET developer and was looking for someone to critique my implementation of a NewtonSoft Json.Net serialiser.
Can you provide some ...
10
votes
2answers
7k views
Writing a bitmap image from C++
Here's my function that creates a bitmap file from an array of pixels. It can write a bitmap both with transparency and without transparency. Please review my code and give constructive criticism on ...
10
votes
1answer
226 views
Organization data class
I believe I have made the following data class quite decently, and I'd like a thorough review on it.
The code is built on Java 8 and uses the Builder and Serialization Proxy pattern, it is used to ...
10
votes
1answer
16k views
Type-length-value (TLV) encode/decode
I wrote these methods to encode data as array of TLV objects, and also to serialize and deserialize them. Any feedback on improvements, etc. would be appreciated.
Please note that I ignored ...
10
votes
1answer
1k views
Rendering an HTML form based on a specification in a string
Here's a brief explanation of my method:
Provide a string and parse it to HTML code respecting a specific format.
The accepted format is:
For dropdown menu : Test DropDown~Select:Options1; Options2;...
10
votes
4answers
7k views
Persistent cookie support using Volley and HttpUrlConnection
I need to add support for persistent cookies on an Android app that I'm building for Authentication/Authorization. This app uses Volley for making HTTP requests and its ...
10
votes
2answers
110 views
Racetrack game with reading the track from a file
For this community challenge I made the racetrack game. I'm reading the race data from a text file, which is available here. This is only playable by entering the velocity at the console.
I've got ...
10
votes
1answer
4k views
Inspector interface serializer
I've written some code that allows Unity3D's inspector to display fields that conform to an interface. Unity has some quirks about their inspector, so as a preface they are listed here:
If you add a <...
9
votes
4answers
4k views
reinterpret_cast vs bit shifts for extracting 32-bit integers from bytes, with either endianness [closed]
I've written some simple helper functions that read data types from a vector of bytes (binary files) and having a tough time deciding which route to go.
Method 1 : reinterpret_cast
...
9
votes
2answers
2k views
Optimize a generic foreach method that converts Datatable to my object using Reflection
I need to optimize this code block below, this method converts a Datatable object to the Object that I am passing by parameter, in another words, this serializes the object, however I have to run this ...
9
votes
2answers
21k views
Effectively convert little endian byte slice to int32
I have a data stream of bytes and I'd like to get a little endian encoded int32 from four bytes. Is there a better way than to do this like the following code?
...
9
votes
3answers
15k views
Serialize C# objects of unknown type to bytes using generics
Usage example
var qm = new QueueMessage("foo", 99);
var ba = ByteArraySerializer<QueueMessage>.Serialize(qm));
Class that performs the serialization / ...
9
votes
2answers
846 views
Reading binary files in XTF format
I have a few thousand binary files that have corresponding structs in them, followed by any number of bytes (this exact number of bytes is given in one of the fields in the structs). I read in data ...
9
votes
2answers
9k views
Type to byte array conversion in Swift
I need the byte representation of a given type, especially double, float, int8, etc.
...
9
votes
1answer
97 views
Writing data into an image
I've done a script that will write things as images, which can then be read elsewhere (eg. you could share an mp3 through imgur). This is the first one I've done where I've been trying to improve my ...
9
votes
1answer
261 views
Interpolating given value and legacy value from serialization buffer
Here's a function that interpolates between a given value and a value fetched out of a legacy serialization buffer:
...
8
votes
3answers
8k 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, ...
8
votes
3answers
360 views
Sinclair Spectrum TAP file dumper
The other day, I had occasion to want to look into an ancient piece of Z80 software written for a Sinclair Spectrum computer. Software for this machine was typically saved to audio tape, and today ...
8
votes
2answers
284 views
A tiny library for textual serialization of lists in Java
Note: see the next iteration.
I have this tiny library for (de)serializing lists of objects. The requirement is that each object's state may be represented textually as a single line of text. Later ...
8
votes
2answers
17k 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.
<...
8
votes
2answers
485 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 ...
8
votes
2answers
9k views
Converting a SecureString to a byte array
Does it allocates something that hasn't freed? Something that remains in memory? Except result byte array, ofc.
...
8
votes
3answers
2k views
Binary serialization library
I am currently working on a binary serialization library written in C++11 for a personal project. I'd really like to have a review about my design, my implementation and everything else. The library ...
8
votes
4answers
1k views
Packet Factory design for networking application
I'm working on a network application that implements a custom protocol. I want to easily extend the application support over the protocol as it changes. Also, as the application extends, I might need ...
8
votes
1answer
181 views
Saving bytes instead of objects to write smaller files
This question is about reducing the size of files saved to disk in an infinite world 2D mining game.
I finally added code to my game to save and load distant chunks instead of keeping all of them ...
8
votes
1answer
602 views
Improve this reflection bashing code
I have implemented an IDataContractSurrogate to enable serialization of ImmutableList<T> (from the Microsoft Immutable ...
7
votes
3answers
4k views
Converting a boolean list to string, and vice versa
I am currently using this to convert a List of booleans to a string
...
7
votes
3answers
468 views
Convert binary raster file to text CSV
I have a binary file input.hgt from the Shuttle Radar Topography Mission. It contains a 3601✕3601 matrix, stored as 2-Byte big-endian integer numbers. My code ...
7
votes
4answers
10k 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 ...
7
votes
2answers
240 views
Querying Facebook for details of a user's OAuth token
This class exposes the public method getAuthToken which takes a user's Facebook OAuth token as an input parameter and queries Facebook for information about it - ...
7
votes
1answer
5k views
Serializing objects to delimited files
For a new project I'm going to need to be able to serialize random types to TSV or CSV files, so I write a class which can be used to serialize any object to a TSV, CSV or any other _SV file you can ...
7
votes
1answer
1k views
Python compress and send
The following two functions are used to compress arbitrary Python objects and send them safely via socket or email, using only printable chars. In my specific message protocol, '=' signs are also not ...
7
votes
2answers
78 views
constexpr Precalculate size of serialized data with templates and C++20 concepts
Im writing a serializer that will do serialization/deserialization as fast as possible, and that uses templates so that i dont have to create a ton of functions for every data structure,
This is the ...
7
votes
1answer
15k views
Hex String to Bytes (NSData)
I'm trying to convert this Objective-C code (originally found in this Stack Overflow question) which turns an NSString into ...
7
votes
1answer
15k 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 ...
7
votes
3answers
156 views
Saving and restoring RadixTree object
I have a large word-file which is fixed with over 240 000 words. I need to check if a specific word exists in this list. I thought that it would be a good idea to create a ...
7
votes
1answer
754 views
Save Games on iOS with NSCoding
This is the second time I have implemented saving and loading for a game using Objective-C. I am using the built in NSCoding methods. I would love to hear opinions about NSCoding and whether or not ...
7
votes
1answer
2k views
A little Python hex editor
First off
I'm quite new to Python, there will be a lot of messy/overcomplicated code, that's why I'm posting on this site.
This code is written in Python (2.7) using the Tkinter library.
Questions
To ...
7
votes
1answer
181 views
Library for managing sub-byte named bitfields
When writing custom network serialization in Rust, I've come across a use case for storing and retrieving values in bitfields smaller than the u8 available in Rust. ...
7
votes
1answer
1k 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, ...