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
7
votes
4answers
9k 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
115 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
217 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
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 ...
5
votes
2answers
105 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 ...
7
votes
1answer
14k 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 ...
5
votes
2answers
473 views

Packing and unpacking bits (2)

Part 1 here. I improved my code from my previous question (linked above). ...
6
votes
2answers
2k views

Packing and unpacking bits

Part 2 here. I wrote this class for packing data. Would it benefit from being named BitPacker rather than BitStream (and change write/read to pack/unpack), or it works as is? How can I improve it? ...
2
votes
1answer
1k views

Encoding a list of frequencies as WAV audio

This code gets a list of signals with predefined frequency from struc.num I need to encode it to wave format, so i use this code. This works, but i dont sure it is a correct decision to encode like ...
6
votes
1answer
229 views

Correct and portable serialization

So I've made custom binary streams which work like this: ...
9
votes
2answers
828 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 ...
2
votes
0answers
232 views

Binary protocol variability V3.0

Summary: Parsing an incoming stream of events from a binary communication protocol, if we have some variations in devices to support and would not like to have one huge switch to include everything. ...
2
votes
1answer
169 views

Save/Load GridView layout using SettingsService

I am able to save my GridView layout by storing a string representation of the items in the ...
4
votes
2answers
211 views

Binary protocol variability V2.0

Up-to-date Version of this question: Binary protocol variability V3.0 Summary of the problem: Parsing an incoming stream of events from a binary communication protocol, if we have some variations in ...
4
votes
3answers
169 views

Netstring parser in common lisp

Below is a netstring parser I wrote in Common Lisp. The docstring contains the usage and return. ...
3
votes
3answers
459 views

Binary protocol variability

Please note: An updated solution is here Let’s imagine that we designed more or less universal firmware for a microcontroller unit to be used across multiple types of devices. So we have something ...
0
votes
2answers
8k views

Returning a byte array from a method [closed]

public abstract class Element { // Removed for verbosity ... protected abstract byte[] GetBytes(); } I'm attempting to create an engine that can create a ...
1
vote
0answers
243 views

.NET List Serializer design

A few weeks back I wrote a class to help serialize/deserialize objects file. The file format requested was json, then compressed. After some coding/testing I settled on this design: ...
3
votes
1answer
742 views

Serialize and deserialize n dimensional int array

I've made two symmetric methods which serialize an int array of any number of dimensions into an OutputStream, and read such an array from an InputStream. I was wondering if there is ways this code ...
2
votes
1answer
1k views

Class for serializing generic gson objects

I realized I had just created two classes that were virtually identical for simply saving objects to their own json files, so I've attempted to make it more generic. My only noticeable problem is ...
4
votes
1answer
159 views

LEB128 in Haskell

I have implemented the LEB128 encoding for unsigned integers. I'm fairly new to Haskell so I have some doubt about the coding style I'm using, particularly the definition of ...
4
votes
1answer
160 views

How to separate data from logic when serializing types - grid tile map example

I am creating a tile based game in Unity and ran into a problem with my architecture of the Map and Tile types. The tile class contains logic like events when the tile type changes. When I tried to ...
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 ...
2
votes
3answers
771 views

Code Smell in Unit Testing Serialized Classes

I can feel that something is wrong with my code. Here's an excerpt where I think the code smell is... ...
1
vote
3answers
797 views

Byte array to floating point such as FPE2 in Java

Apple's System Management Controller uses FPE2 and SP78 as floating-point formats. While writing a Java library that that interfaces with the SMC, I ported someone's C function to convert read a FPE2-...
1
vote
1answer
63 views

XSD Schema for optical media

I recently wrote my first XSD Schema: ...
12
votes
2answers
455 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,...
2
votes
2answers
107 views

Generated serialization code

CGbR project I am currently working on a project that generates code from classes. The idea is to achieve maximum performance by replacing reflection use cases with fast, generated code. Current ...
0
votes
2answers
340 views

Submitting a form via JSON

I have a file named feedback.js that I would like to improve. ...
2
votes
1answer
61 views

Something to store any (standard) data in python

I decided to try make my own way to save normal python data yesterday after coming across the minecraft NBT format, it's more limited than cPickle but appears to produce shorter results and so far ...
0
votes
1answer
775 views

Create Xml to string serializer

I don't want to serialize everything. I created a custom attribute DoNotSerializeAttribute. If some property in info contain ...
1
vote
1answer
1k views

Object parser in C++

Consider the following contrived data type: Building: int age, char* location, float ...
1
vote
0answers
163 views

Saving the state of a ViewModel

I've the following scenario, I've got some viewmodel that need to persist their state on disk. I've defined a custom attribute as: ...
2
votes
1answer
162 views

Vigenère cipher as an IO filter

I implemented a Vigenere encoding and decoding class. Ideally, the program should be able to take any abritrary file, read into an array of byte, and decode it. ...
2
votes
1answer
5k views

A Dynamic CSV Serializer

I made a dynamic CSV serializer as a learning challenge a while back, I'm hoping to get my code picked apart so I can learn what I can do better. This is a bit long, so I wouldn't expect anyone to ...
6
votes
1answer
4k views

Reading bytes from packet

I have a device I connect to on TCP socket. I send it a message with what I want and it sends back all sorts of useful information: Header: ...
2
votes
0answers
2k views

Reusable REST service class for Angular2 in TypeScript

I am creating an Angular 2 web application using TypeScript. This application performs REST requests to a REST "service". For each REST resource in my service I create a separate "Service" class in ...
0
votes
1answer
108 views

Reading many kinds of numbers from a byte buffer

I've been trying to find a way to collapse all these methods into one. Current I have these methods ...
6
votes
1answer
266 views

Polymorphic TLV serialization

Inspired by this question I decided to write an alternative that uses polymorhphism and a Factory pattern. The code works for the subset of implemented types, namely ...
6
votes
1answer
3k views

TLV implementation in C++

I tried implementing TLV(https://en.wikipedia.org/wiki/Type-length-value). Actually my implementation is more than TLV because it supports additional "Tag" elements (which you can use for naming ...
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. ...
7
votes
2answers
230 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
2answers
126 views

Updating resources while avoiding race conditions

I am writing a utility class for a game client. This class has two main functions: connect to a game server and retrieve the current game revision, and retrieve a "recipe", which is basically ...
6
votes
3answers
2k views

Advanced formatting with argument passing

I want to customise how my objects are printed using the .format() function. I have two problems to make that happen in clear and concise way. But since the second ...
4
votes
3answers
596 views

Format of hexeditor

Is there a cleaner way to write this code? It's the start of a hexeditor I'm creating. I'm aware that the variables aren't descriptive, this is just a test run for when I imbed it into a File ...
4
votes
1answer
61 views

Which loop to use for multiple if statements which serialize objects

I have figured out how to serialize multiple objects, however I am utterly convinced I can use some kind of loop for the if statements below, to avoid duplication. Please can someone advise how I ...
3
votes
1answer
2k views

Serializing multiple objects to a file

I am very new to Java and although my code works, I know that it must be possible to write this using fewer lines of code. I am serializing multiple objects, eventually I will look into serializing to ...
1
vote
1answer
329 views

Dynamic CSV Formatter

I made a dynamic CSV formatter as a personal challenge after having to hardcode a behavior to convert some data to CSV earlier. You input any List that contains supported types as properties (all ...