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
5
votes
2answers
407 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
217 views

Correct and portable serialization

So I've made custom binary streams which work like this: ...
9
votes
2answers
751 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
158 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
205 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
155 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
449 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
7k 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
233 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
623 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
143 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
147 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
4k 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
685 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
625 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
62 views

XSD Schema for optical media

I recently wrote my first XSD Schema: ...
12
votes
2answers
397 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
104 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
312 views

Submitting a form via JSON

I have a file named feedback.js that I would like to improve. ...
2
votes
1answer
58 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
733 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
149 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
4k 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
105 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
248 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 ...
8
votes
2answers
8k 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
204 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
120 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
1k 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
594 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
1k 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
308 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 ...
4
votes
1answer
494 views

Generic methods for serializing and deserialzing xml files using streams followup

Recently I asked this question: Generic methods for serializing and deserialzing xml files using streams However it has come to my attention that this gives me an (harmless) exception when trying to ...
5
votes
2answers
978 views
1
vote
1answer
65 views

WebService --> XML Cache Repository

I'm working on a small application that uses a WebService to get meta-data about television episodes. What I'd like to do is start building out a local cache of the series so that I can reduce the ...
5
votes
6answers
815 views

__repr__ for a binary tree whose constructor has default arguments

I recently have been working on a BinaryTree class, and looked into creating a proper __repr__ which when eval'ed would recreate ...
2
votes
0answers
249 views

Better way to deep copy than this? How can I make it generic by `Collection` type?

Could I make this method for deep copy generic to the Collection type? That method is so simple and I can't imagine ever needing to change it, so maybe I should ...
1
vote
1answer
404 views

Pool readers and streams with Json.NET

This code is built on Json.NET and gets called hundreds of times per second. My data starts in an ArraySegment<byte>. I wrap that in a ...
11
votes
7answers
7k 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. ...
2
votes
1answer
64 views

Three ways to read a number for a BitInputStream

I'm trying to learn how to write more readable code without introducing easily avoidable performance killers. This is part of a BitInputStream Java class I'm ...