33,518 questions
Tooling
0
votes
8
replies
66
views
What is the easiest way to convert nested JSON to Python dataclasses automatically?
I'm working with complex nested JSON responses from an API and want to convert them into strongly-typed Python dataclasses for better code completion and type safety.
Currently, I'm manually creating ...
Best practices
2
votes
15
replies
284
views
How to properly serialize raw binary data in C/C++?
What is the preferred way to serialize data to raw byte array (without any serialization libs)? I though these variants:
#pragma (pack,1) struct A{...} #pragma (pop) or __attribute((packed))__ ...
0
votes
0
answers
45
views
How to force reflection free jackson serializers generation
I wonder if there is any way - apart from creating a dummy REST API - to force Quarkus to generate reflection free jackson serializers and deserializers?
My service exports data in JSON and stores ...
-5
votes
0
answers
56
views
How to force a specific field order in JSON output using Jackson? [duplicate]
I need my JSON output to show the "idTransanction" and "details" fields first for logging purposes. Currently, Jackson alphabeticalizes them or follows a random order. Is there an ...
Best practices
0
votes
7
replies
130
views
How do I serialize a floating point number?
In the past I've written code to manually serialize a binary representation of a IEEE 754 number, however, it seems like several projects simply reinterpret a floating point number as a byte array and ...
3
votes
1
answer
138
views
Serialize and deserialize property with dynamically assigned property name based on a type given in an attribute [duplicate]
I'm using newtonsoft.json.
I've got classes created from XSD to C#.
Inside these classes are some properties whose names should dynamically change when serializing in XML, based on the type to as ...
3
votes
1
answer
106
views
Serialising and Deserialising a System.Data.DataSet to XML with SQL Server UniqueIdentifier using different .NET versions
We have a legacy application that was originally written to connect directly to a SQL Server database using OLEDB.
Since then we have introduced Azure SQL databases (but some of our clients are still ...
2
votes
1
answer
161
views
How to set up Instant format with Jackson serialization/deserialization
I'm using jackson-module-kotlin:2.21.0 and jackson-datatype-jsr310:2.21.0.
I need to serialize (and then deserialize) java.time.Instant in specified format "yyyy-MM-dd HH:mm:ss"
(without ...
0
votes
0
answers
25
views
Redisson RMap.getAll() returns incorrectly deserialized objects for large batches, but works for small batches or single get
I am using Redisson RMap as a cache and fetching data in batches using getAll().
Original code
private static final int FETCH_LIMIT = 1000;
private void getResponseForSubsetOfKeys(Set<Object> ...
Advice
0
votes
2
replies
42
views
How can Unity YAML scene files be interpreted in an external runtime?
I'm working on an experimental project called NextLiber VRM, which attempts to interpret Unity scene files outside the Unity runtime.
Unity stores scenes in YAML format, including transforms, ...
2
votes
1
answer
130
views
C# XML Serialization: Merging multiple lists before saving
I am currently working on a small financial management application and use XmlSerializer to persist my data. I maintain a main list (allRecords) holding all data, and two separate lists (incomeList ...
0
votes
0
answers
36
views
Serialization with MSR 010B [Flush Command] in AMD CPUs for execution time measure
AMD Processor Programming Reference (PPR) for AMD Family 19h Model 70h, Revision A0 Processors says:
MSR0000_010B [Flush Command] (Core::X86::Msr::FLUSH_CMD)
Writes to this register do not execute ...
2
votes
1
answer
154
views
Newtonsoft for ISerializable classes with a reference loop - use GetObjectData for serialization and ordinary constructor for deserialization
I have a couple of ISerializable classes (simplified):
internal interface IBase : ISerializable
{
int Number { get; }
}
internal interface ITable : IBase
{
ISection Section { get; }
}
[...
3
votes
1
answer
179
views
Deserialization via Newtonsoft for classes with a reference loop, private constructors and private/internal properties setters
I have a couple of classes (simplified):
internal interface ITable
{
int Number { get; }
ISection Section { get; }
}
internal class Table : ITable
{
public int Number { get; private init; ...
2
votes
1
answer
72
views
Django / Serializer - How to pass label attached to choice field in API?
I am trying to get the label attached to the relevant interger for the choice field. Although the API returns the interger, I cannot seem to be able to return the actual label value.
This is the ...
1
vote
1
answer
368
views
Serializing of polymorphic json in ASP.NET Core 10
I want to use polymorphic JSON for the RichText type in .NET 10 because I plan migrating from one richtext format to another and I am stuck with a problem: when the object is automatically serialized ...
-1
votes
1
answer
66
views
Unity UWP build: “A scripted object probably BlankScene has a different serialization layout” when using [SerializeField]
I'm encountering a serialization error when building a Unity project for UWP and running it in Visual Studio:
A scripted object probably BlankScene has a different serialization layout when loading (...
1
vote
1
answer
308
views
kotlinx-serialization-json 1.9.0 library causes compile error "Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin."
After adding the dependency org.jetbrains.kotlinx:kotlinx-serialization-json:1.9.0 I tried using it like this:
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.Json
@...
0
votes
1
answer
58
views
KafkaAvroSerializer UnresolvedUnionException with nullable timestamp-millis field
I'm using confluent's KafkaAvroSerializer with a schema that includes a nullable timestamp-millis field. The field maps to Instant in Java, but when I send a non-null I get an UnresolvedUnionException....
1
vote
1
answer
149
views
Callback methods with ProtoBeforeSerialization/ProtoAfterDeserialization donot work in protobuf-net 3.2.26, even when assigned explicitly to MetaType
I'm upgrading from protobuf-net 2.2.1.0 to 3.2.26, and I've noticed that callback methods decorated with [ProtoBeforeSerialization] and [ProtoAfterDeserialization] are no longer invoked during ...
7
votes
1
answer
160
views
Records don't deserialize cycles
I stumbled upon something that got me curious. Apparently, serializing a record with a cyclic reference does not retain the cycle when deserializing it again, it becomes null. When doing the same ...
0
votes
0
answers
123
views
pywebview: error maximum recursion depth exceeded before pressing button when passing pandas/model objects in js_api
I’m embedding a small UI with pywebview and want Python to JS live updates. I created a GPSSpoofingDetector class that loads a pickled sklearn model and a pandas test CSV. I want a JavaScript “Start” ...
0
votes
0
answers
86
views
DiskReadViolation on Ktor with json negotiation
My StrickMode and Ktor HttpClient setup on Android
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
import io.ktor.serialization.kotlinx.json.json
override fun onCreate(...
1
vote
1
answer
110
views
Cannot override writeObject (Serializable model) method in AnyLogic
I have a model based on AnyLogic and tried to serialize it, but receive an StackOverflow error. As I understand the main reason is a circular agent reference. I can't find it however.
I tried to ...
3
votes
1
answer
209
views
How to use Pydantic field in another field for serialization/deserialization purposes
I would like to solve the following problem with Pydantic (latest version), with Python 3.x.
While deserializing, I want to use the field "path", path contains another array that I want to ...
1
vote
1
answer
48
views
An object with a Redis object in its attribute can't be serialized. How to modify it for serialization without delaying the connection?
When writing a multi-process program for web scraping, I passed an object of my custom RedisQueue class as an argument to the multi-process task function. This class contains a Redis object as one ...
1
vote
2
answers
103
views
Flink GenericType List serialization
In my Flink app, I found this log:
Field EnrichmentInfo#groupIds will be processed as GenericType. Please read the Flink documentation on "Data Types & Serialization" for details of the ...
1
vote
1
answer
109
views
XmlTextAttribute Breaks Formatting When Serializing
I'm trying to output xml to input into a 3rd party library that needs the following format (simplified & without xml declaration)
<root>
ImportantText
<IntegerVal>123</...
2
votes
1
answer
156
views
Deserializing Interface Types in C# projected on records
I'm deserializing interfaces mapped to usual classes with a custom IJsonTypeInfoResolver. The resolver looks similar to this:
public class InterfaceMappingResolver : IJsonTypeInfoResolver
{
...
0
votes
0
answers
79
views
Preventing obfuscation not working with setter
I'm using a custom technique for super easy JSON decoding,
using abstract getters/setters and noSuchMethod override.
However the pragma to prevent obfuscation works with getters but not with setters.
...
0
votes
1
answer
447
views
Use msgspec to (de-)serialize Python objects without hard-coding serialization library in data classes
I want to use JSON to serialize and deserialize a complex Python object. This Python object contains other Python objects that may be implementations of a protocol or descend from a common abstract ...
2
votes
2
answers
123
views
(De-)Serializing with Nested Closed Polymorphism
In this thread, (de-)serializing a nested polymorphic object is described for open (runtime) polymorphism. How can the same be achieved for closed (static) polymorphism? That is, how can a ...
1
vote
2
answers
135
views
Deserializing Java object streams with different serial version IDs
I am trying to load data from Java object streams from another application. Since I do not have access to the source code of that application, I used jdeserialize to extract the class definitions from ...
0
votes
0
answers
41
views
mlSerializer: "Types 'Base.ClassTest' and 'Message1_0.ClassTest' both use the XML type name 'ClassTest'" when serializing inherited classes
I am working with XML serialization in C# where I have multiple versions of a message class that inherit from each other.
Here’s a simplified version of my code:
namespace XMLSerializeProblem.Base
{
...
0
votes
1
answer
269
views
Confusions with how Laravel's Job serialization and deserialization works
What happens to the model's eager-loaded relationship when the model is passed to another Job's dispatch method?
Context:
There is a job that retrieves all ongoing games and this job should create an ...
1
vote
1
answer
85
views
Serializing and compressing std::map using Boost [closed]
I'm trying to serialize and compress a std::map using Boost. Here's the serialization code:
#include <boost/archive/binary_oarchive.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#...
1
vote
0
answers
422
views
C# MessagePack serialization/deserialisation while maintaining object reference
I am using MessagePack version 3.1.4 for binary serialization/deserialization. With the most basic code and decorating my fields/properties with the Key attribute:
public static byte[] Serialize<T&...
2
votes
2
answers
194
views
How to deserialize list of objects in Quarkus using Kotlin serialization?
I need to deserialize JSON body of POST method into list of objects. So I have next quarkus service:
import jakarta.ws.rs.POST
import jakarta.ws.rs.Path
@Path("/")
class MyService {
@...
3
votes
1
answer
522
views
How can I iterate over struct fields at compile time in Zig to generate a serializer?
I'm learning Zig and I'm trying to write a generic function that automatically serializes any struct into JSON. In languages like Rust or Go, there are libraries that can iterate over the fields of a ...
1
vote
1
answer
76
views
Removing a JSON element that should be an array
I am trying to use RestSharp to deserialize a JSON return into C# classes. The return sometimes contains a single, empty object when the data definition calls for an array of objects. If there is ...
1
vote
0
answers
107
views
Kotlin serialize simple class with explicit Serial Name
I've tried to use kotlinx.serialization with the third party Yaml plugin from @charleskorn.
In the past I already did something with Python using pyyaml, where I explicitly set a custom yaml_tag for ...
0
votes
2
answers
80
views
how DRF undestand which field in serialazer.py is related to which model field?
imagine i have a super simple serializer.py file :
and i just want to use it ! nothing special ..
so im going to write something like this (with a model class called "Product") & its ...
0
votes
0
answers
75
views
ASP.NET Web API - Model binder validation property name
I have a basic ASP.NET Web API project. When I send a request, the serialization is done using System.Text.Json. However, when I send a non-valid json, for example text instead of number, it returns a ...
-1
votes
2
answers
123
views
How to deserialize JSON object with nesting [closed]
I am trying to deserialize a JSON object:
{
"columns":"1",
"ctrl":{
"height":"24",
"offcolour":"#ff000000",...
0
votes
0
answers
245
views
Could not load file or assembly 'System.Runtime.Serialization.formatters' in .NET 8 WinForms application
I get the error
System.IO.FileLoadException: 'Could not load file or assembly 'System.Runtime.Serialization.Formatters, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Could not ...
2
votes
1
answer
167
views
javac 21 Xlint not showing warnings for missing serial version ID on an anonymous class unlike Eclipse
I have a Maven parent POM that configures the Maven Compiler Plugin like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</...
0
votes
0
answers
83
views
Spring boot: Jackson won't parse concrete type
I'm using Spring Boot (latest version).
I have this 4 classes. SubtypeDTO inherits from abstract class TypeDTO, ClassUsingSubtype uses SubtypeDTO and ClassUsingType uses TypeDTO. I need all of them!
@...
2
votes
2
answers
148
views
Serialize/deserialize a ReferenceLoop of ISerializable objects with Newtonsoft.JSON (Json.NET)
Preamble: I know about ISerializable deprecation. We have to use it because we have massive legacy codebase for IPC (that uses this interface). We are migrating from .NET Remoting to a crossplatform ...
1
vote
0
answers
62
views
How to deserialize JSON in C#? Is the input format data correct? [duplicate]
I need to deserialize a JSON data containing list of players into a regular List<> type (in C#). My code is:
public async Task<Player2> RetrievePlayerListFromServer()
{
...
1
vote
1
answer
66
views
SerializationException: Serializer for class 'QuoteResponse' is not found
I am trying to show quote on my app via an api. I have updated all the dependencies, plugins and libraries. I tried with a dummy api, the result was getting updated in the app then I tried with ...