Skip to main content

New answers tagged

Best practices
0 votes
0 replies
0 views

How to properly serialize raw binary data in C/C++?

No you actually don't. The endianness of the system is irrelevant, the bitwise operations (e.g. bitwise shifting operators and so on) already do the abstraction for you. All you have to define is the ...
Fareanor's user avatar
  • 7,497
Best practices
1 vote
0 replies
0 views

How to properly serialize raw binary data in C/C++?

One big problem with binary serialization is when you have to deal with different endian representations between the serializer and deserializer. In such an environment it almost impossible to just ...
Thibe's user avatar
  • 762
Best practices
0 votes
0 replies
0 views

How to properly serialize raw binary data in C/C++?

What do you mean with "No endian related issues"? Just knowing that you are in a different endian system does not help to deserialize the data. You need to know the sizes and locations of ...
Thibe's user avatar
  • 762
Best practices
2 votes
0 replies
0 views

How to properly serialize raw binary data in C/C++?

First preference for binary serialization is to use some existing library. There are many (like flatbuffers, protobuf, cbor etc.) and tools for these solve most issues with that, generate code for you ...
Öö Tiib's user avatar
  • 11.1k
Best practices
1 vote
0 replies
0 views

How to properly serialize raw binary data in C/C++?

But looks very ugly. I disagree. It looks totally fine and looks are subjective.
Richard's user avatar
  • 49.6k
Best practices
1 vote
0 replies
0 views

How to properly serialize raw binary data in C/C++?

Serializing raw binary data is an Oxy-Moron. If you are serializing it you are transforming it in some way, while raw binary data is not transformed, so you are just copying what is in memory to some ...
Loki Astari's user avatar
Best practices
7 votes
0 replies
0 views

How to properly serialize raw binary data in C/C++?

My question to you is: Why do you need to do serialization/deserialization yourself? There are many existing libraries good which can handle it for you, that are tried and tested, and will let you ...
Some programmer dude's user avatar
0 votes

How to remove null values generated by a jackson custom serializer?

This needs two things now. The member needs to have the annotation @JsonInclude(NON_EMPTY) and the serializer needs to implement: public boolean isEmpty( final SerializerProvider provider, ...
Diastrophism's user avatar
  • 15.5k
Best practices
1 vote
0 replies
0 views

How to properly serialize raw binary data in C/C++?

It depends really on the use case, even if your struct has padding in it, you can still `memcpy` it. If possible you can also re-order the fields to get rid of (most of) the padding. Why do you want ...
Reinder's user avatar
  • 345
Best practices
1 vote
0 replies
0 views

How to properly serialize raw binary data in C/C++?

serialize to me accomplishes: For byte data consider base64 or the like No endian related issues: Send integer data MSB first. ASCII: Only use a few control codes and ASCII 32-126 FP is converted to ...
chux's user avatar
  • 159k
Best practices
2 votes
0 replies
0 views

How to properly serialize raw binary data in C/C++?

To my knowledge, there is no preferred method of serialization and deserialization. Most people say to use a library. I prefer using a uint8_t array, copying the data to the array (serializing) or ...
Thomas Matthews's user avatar
Best practices
1 vote
0 replies
0 views

How to properly serialize raw binary data in C/C++?

memcpy is your guaranteed way to get the behaviour you want and no undefined behaviour. Just do that, even if it looks ugly (honestly, who cares what it looks like?).
Jesper Juhl's user avatar
  • 32.2k
Best practices
0 votes
0 replies
0 views

How to properly serialize raw binary data in C/C++?

What compiler are you using? The #pragma is usually compiler specific and not standardized (for packing an array or structure).
Thomas Matthews's user avatar
Best practices
1 vote
0 replies
0 views

How to properly serialize raw binary data in C/C++?

If the goal is to de-serialize it on the other side, the first approach without any pragmas and attributes will work as long as both sides have the same representation of the structure (that is data ...
Eugene Sh.'s user avatar
  • 18.7k
Best practices
0 votes
0 replies
0 views

How do I serialize a floating point number?

IEEE754 is indeed pretty commonplace amongst today's CPUs. Not all CPUs exclusively use IEEE754; some have other representations to (e.g. POWER's decimal representation that is also on the chip as ...
bazza's user avatar
  • 8,625
Best practices
1 vote
0 replies
0 views

How do I serialize a floating point number?

Interesting point about SNaN vs. QNaN. If you don't unmask the "invalid" FP exception, and aren't checking fenv to see if comparisons caused an invalid exception, you can just leave it. ...
Peter Cordes's user avatar
Best practices
1 vote
0 replies
0 views

How do I serialize a floating point number?

Sure, that's why I wrote to build in a static_assert or other similar test. However, I believe you should not spend any more time on that. On the rare occasion that your code is ported to a machine ...
Homer512's user avatar
  • 15.4k
Best practices
3 votes
0 replies
0 views

How do I serialize a floating point number?

I'm sure there are duplicates of this question, but just as a quick answer: Yes, IEEE-754 is standardized enough that a simple memcpy works fine and you only need to worry about endianness. They are ...
Homer512's user avatar
  • 15.4k
Best practices
0 votes
0 replies
0 views

How do I serialize a floating point number?

Well, I also know just two cases where a different floating-point number type is used. But those cases are so marginal...
Sergey A Kryukov's user avatar
Best practices
1 vote
0 replies
0 views

How do I serialize a floating point number?

Well, you do say IEEE 754, which is the particular binary format that most computers have come to standardize on. It is not universal, though.
500 - Internal Server Error's user avatar
Best practices
2 votes
0 replies
0 views

How do I serialize a floating point number?

The problem of serialization is completely unrelated to CPU presentation. IEEE 754 does not reinterpret anything. It defines binary representation of the floating-point numbers, semantic meaning of ...
Sergey A Kryukov's user avatar
0 votes

Save serializable object to registry in .NET?

I can't believe nobody said anything like: you really should be serializing an array of values to an array of keys, the way Windows does Power Policies, for instance: So given a list of your objects ...
Jaykul's user avatar
  • 15.9k
6 votes
Accepted

Serialize and deserialize property with dynamically assigned property name based on a type given in an attribute

You would like a way to serialize a model using Json.NET that handles polymorphic properties in the same way that the XmlSerializer can handle polymorphic properties: For each property, the set of ...
dbc's user avatar
  • 121k
2 votes

Serialising and Deserialising a System.Data.DataSet to XML with SQL Server UniqueIdentifier using different .NET versions

Theoretically you could use a bunch of assembly bindings for the relevant types causing an issue, from the deserialization side. But the best bet might be to just chop off the assembly name from the ...
Charlieface's user avatar
  • 80.4k

Top 50 recent answers are included