8,199 questions
0
votes
0
answers
26
views
How can I use a custom Date deserializer for Json RequestBody?
I'm using Spring MVC and I would like to control the deserialization of Date objects in RequestBody.
I saw I can set a custom JsonDeserializer in the input object, but I would like to set a global ...
0
votes
4
answers
112
views
Deserialization backward compatibility when type of property has changed
I used to have simple classes like below:
public class Product {
public Money Price {get; set;}
}
public class Money {
public decimal Amount {get; set;}
public CurrencyEnum Currency {get;set;...
0
votes
1
answer
136
views
Deserializing array of objects to concrete .NET types using Newtonsoft
I have a couple of classes (simplified):
internal class OrderItem
{
public string Name { get; set; }
public Order Order { get; set; }
}
internal class Order
{
public IReadOnlyList<...
4
votes
1
answer
99
views
Deserialization of XML with multiple namespaces
I'm attempting to deserialize an XML response from an API. The data is as follows (I have only included a small chunk for the sake of a small post):
<ns1:alerts xmlns:ns1="http://gov.fema....
-3
votes
1
answer
79
views
Deserialize Json string on POST when result is returned in [X].Name format
Everything works as expected until the json string is deserialized after the post back.
Class:
public class RegretLetterDetail
{
public int PositionID { get; set; }
[Display(Name = "...
7
votes
1
answer
153
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
1
answer
258
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
110
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
115
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
110
views
Spring OAuth2 Authorization Server: IllegalArgumentException when deserializing custom User class after consent approval
I'm trying to set up a Spring Authorization Server for learning purposes. The login and consent screens work, but after I approve the consent screen and submit the /authorize request, I get the ...
0
votes
1
answer
153
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
81
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>
#...
0
votes
0
answers
266
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
0
answers
119
views
In Pydantic 2, how do allow missing fields during deserialisation/validation, but require it when creating an instance?
I use pydantic to be able to serialise and deserialise json data stored in a large database. Each of these json strings represent a pydantic model MyModel.
class MyModel(BaseModel):
attr1: int
I ...
0
votes
1
answer
130
views
Python UnpicklingError: invalid load key, '\xef' [closed]
I am new to python and came across a object deserialisation issue (unpickling) while testing a program on jupyter lab.
I am trying to serialize and deserialize object of Employee class as below.
- ...
2
votes
2
answers
238
views
Jackson Custom Deserialization - deserialize into known object instance WITHOUT JsonTypeInfo annotations or Mixins
I have a class BaseClass that during runtime will store a reference to another object Thing. BaseClass is meant to be extensible so I've made it abstract like so:
abstract class BaseClass{
// see ...
2
votes
2
answers
129
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
61
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()
{
...
0
votes
0
answers
101
views
Is there a way in TypeScript to do custom JSON deserialization within a class?
The Goal
I am working on a project where we have id's comming back from the server in a format that is a prefix followed by a guid (prefix_{guid}). This is so that we know what the specific ID type is ...
1
vote
2
answers
223
views
Delphi and JSON serialization with Spring collections
I am trying to include the Spring4D framework in my latest Delphi project. The collection functions for sorting and filtering are the main features.
However, I have great difficulty to serialize a ...
0
votes
1
answer
62
views
Jackson custom map deserialization throws "Cannot find a (Map) Key deserializer" exception
I have several sets of parameters that comes from client and I need to parse them.
I make a custom class extended from a HashMap. It is parameterized with map key class which is enum itself. Using ...
2
votes
0
answers
86
views
JavaFX serialization, inheritance and generic types
So I have a class that implements a JavaFX ObservableMap which maps Integers to a generic type T, and I want to serialize that, but it happens that this is an abstract class and what I will in fact ...
1
vote
0
answers
57
views
How can I write a generic hex deserializer for all unsigned integers using Serde and Num traits?
I'm trying to write a generic deserializer function using serde for hex strings like "0xff" to convert into various unsigned integer types (u64, u128, etc). I want to make the function ...
1
vote
1
answer
158
views
Jackson inheritence deserialize causing infinite loop
I'm trying to deserialize JSON data into Animal.class and Dog.class which extends Animal.class using custom deserializer. The JSON data below is a simplified one and the real JSON data cannot be ...
4
votes
1
answer
143
views
Is it possible to write a generic optimal constructor when having access to all fields? (deserialization)
I have some serialization code to persist an object into a DB. This works by mapping an enum value, representing the column, to a member of the class. The type information is preserved this way, so ...
3
votes
1
answer
4k
views
Unable to torch.load due to pickling/safety error
I am trying to use a pytorch model present on this link:
https://drive.google.com/drive/folders/121kucsuGxoYQu03-Jmy6VCDcPzqlG4cG
since it is used by this project I am trying to run:
https://github....
0
votes
0
answers
84
views
Enum Mapping in Oat++ DTOs Causing Runtime & Compile-Time Errors
I'm using Oat++ with custom enums for serializing/deserializing in DTOs and integrating them with a MySQL connector. I'm facing issues when mapping enums to/from JSON and database fields.
I've tried ...
0
votes
1
answer
83
views
Deserialize a cached response into a Kontent ai strongly typed object
I'm using Blazor wasm with .Net 8 and the Kontent.Ai.Delivery package and I'm trying to integrate caching into the system.
One problem I'm facing is, after I store the data as json in cache, I can't ...
0
votes
0
answers
47
views
How to consume message with Xml type using MassTransit.Kafka?
I used the following configuration code for consuming raw message in MassTransit with MassTransit.Newtonsoft library. For XML, the root element will be the same but the children properties will vary. ...
0
votes
0
answers
59
views
Is it ok to suppress there warnings [duplicate]
I have code that has two warnings.
The code is from a commandline Expense manager project that uses a List to save and access expenses. Saving and retrieving the List is done via serialisation and ...
0
votes
1
answer
131
views
Unable to deserialize XML element with namespaces
I have been trying to deserialize an XML file and pull out some data from StructuredText element of the XML. So far, namespace have been causing issues.
I generated the classes with xsd from a schema ...
0
votes
1
answer
135
views
Force Rust serde to deserialize JSON Number to u16
How can I force serde to parse a JSON Number as a Rust u16 type?
Below I parse a JSON file. json_data is of type Value. This only has a as_u64() method, no as_u16(). As a result I first have to parse ...
1
vote
0
answers
136
views
Java 8 date/time type serialization fails
I am using Java 21 with Spring Boot 3 and Spring 6 to send a custom object to an SQS queue.
public class Event {
String eventName;
Instant dateTime;
}
My SQS message listener is set up as ...
0
votes
0
answers
79
views
pydantic get field alias based on field value with python object
I have pydantic model as below.
from typing import Annotated
from bson import ObjectId
from pydantic import Field
from pydantic import EmailStr
from pydantic import BaseModel
from pydantic import ...
0
votes
0
answers
95
views
Unable to perform Jackson deserialisation for boolean and int
My XML
<Parent>
<childs>
<child>1</child>
<child>0</child>
</childs>
</Parent>
Pojo Structure is
class Parent
{
@...
2
votes
0
answers
49
views
Serilialize with thrift to a file performance problem
I'm working on serializations and need to make some benchmarks on Apache Thrift. But I have very long serialization times. Compared to Protobuf, I have more than 100x average times. What am I doing ...
0
votes
0
answers
223
views
Decode program data (UIAccountData) from Solana websocket
I connect to Solana websocket and subscribe to program data of Raydium decentralized exchange account (https://raydium.io/swap/) to listen to swap transactions.
Current State
I successfully connected, ...
0
votes
1
answer
188
views
Is BinaryFormatter used to deserialize images embedded in an application via. .resx files?
In a C# .Net application, is BinaryFormatter used to deserialize resource image data embedded in the application via .resx files and Resource Explorer?
I've been handed a .Net application and the task ...
0
votes
1
answer
82
views
PHP Symfony parse JSON response deserialize class constructor
I am trying to parse this JSON $response body =
{"low":{"networkFee":"0.00003"},"medium":{"networkFee":"0.0000428"},"high":{"...
6
votes
1
answer
90
views
Is there a simple recursive analogue of this breadth-first binary tree deserialization function in Haskell?
I am interested in methods for serializing and deserializing a binary tree in breadth-first order. The first part, serialization, is equivalent to performing a levelorder traversal where we preserve ...
-1
votes
1
answer
81
views
JsonConvert.DeserializeObject<T> always returns T, how to deserialize json as T only if it is T?
I was suprised, that any valid json, even empty "{ }" can be deserialized by JsonConvert.DeserializeObject as any T class. The missing values will simply be default.
To example, I can't do ...
0
votes
1
answer
796
views
Spring Boot @RequestBody Flags Snyk CSRF
I have an API in Spring Boot. In the controller layer, any POST that has a custom object annotated with @RequestBody flags Snyk security findings in the security pipeline.
For example:
public ...
0
votes
0
answers
61
views
Deserializing error with okhttp and fastJson2 while reading a Jackson Model class
try (Response okHttpResponse = client.httpClient.newCall(request).execute()) {
if (!okHttpResponse.isSuccessful()) {
logger.severe("Error in calling Rest API : " +...
0
votes
0
answers
28
views
Improving performance of DataSet.ReadXml by means of DataTable.BeginLoadData: DataSet.EnforceConstraints is left false
In Loading a DataSet from XML, I've found the following statement:
If you call ReadXml to load a very large file, you may encounter slow performance. To ensure best performance for ReadXml, on a ...
1
vote
2
answers
154
views
Creating a trivially constructible object from a char const* without default constructing?
Given a trivially constructible struct with alignment > 1, how can I create that struct with data from a buffer without calling the default constructor?
enum class FoodType {
Fruit, Veggie, ...
0
votes
1
answer
82
views
How to convert a BsonDocument to a given java class object?
private <T> T convertByteInDataForObject(ByteString data, Class<T> toType) {
byte[] bsonBytes = data.toByteArray();
ByteBuffer byteBuffer = ByteBuffer.wrap(bsonBytes);
...
-1
votes
1
answer
148
views
How to Deserialize JSON into C# objects correctly?
I have a function that calls API requests, and I want to have each request return its own data type according to its purpose.
For that, I created a class called ApiResponse. Here is its code:
...
0
votes
1
answer
47
views
Error deserializing FeatureCollection in Kotlin
I'm trying to deserialize a GeoJson FeatureCollection contained in a file (.json extension), with contents:
{
"type": "FeatureCollection",
"features": [
{
&...
0
votes
0
answers
42
views
Trouble with finding right solution for serialization in marshmallow
I have two issues:
I would like to make a generic lowercaseAwareSchema that can take a string as an input (not a dict, a string) and load the string along with its lowercase version in a dict
I would ...