All Questions
Tagged with json serialization
6,903
questions
0
votes
0
answers
26
views
How to read `DeclaringType` from `JsonPropertyTypeInfo` in System.Text.Json?
I want to customize serialization based on the type of the property. To do that I would like to read DeclaringType from JsonPropertyInfo. This is an example from Microsoft documentation on how to ...
1
vote
1
answer
32
views
System.Text.Json.JsonSerializer does not overwrite existing file fully when using file stream
Consider the following code:
internal class Program
{
static async Task Main(string[] args)
{
var t = new Thing() { Name = "Some Long Name" };
string path = @"c:\...
0
votes
2
answers
129
views
"Object of type EXAMPLE_TYPE is not JSON serializable" exception thrown when returning a FastAPI response [duplicate]
The design of my system consists of two parts:
There is a FastAPI webserver interface which wraps some core logic
There is a class which contains all of the core logic, let's call it KeyValueStore ...
0
votes
1
answer
61
views
Gson serialize null only if value equals a specific pattern
Imagine I have an object that looks like this:
@Getter
@Setter
static class MyObject {
private String firstName;
private String lastName;
private long salary;
}
and then I have:
private ...
0
votes
0
answers
66
views
In C#, why does System.Text.Json.JsonSerializer.Serialize fail to serialize correctly when using dependency injection (interfaces)? [duplicate]
Why does the following write out only "{}"?
var myLogin = new TestLogin
{
UserName = "[email protected]",
Password = "Pass123"
};
Console.WriteLine(System.Text.Json....
0
votes
0
answers
30
views
How to deserialize JSON with dynamic substructure? [duplicate]
following JSONs.
Fix parts and a one that will be change for various JSONs.
{
"prop1" : "val1",
"prop2" : 5,
"fixStructure1" : {
"field1" : &...
0
votes
2
answers
100
views
How to deserialize a Map with custom value type in serde?
I have the following json file that I want to deserialize in a Rust struct:
{
"name": "Manuel",
"friends": {
"id1": 1703692376,
...
}
...
}
...
2
votes
1
answer
53
views
Jackson's JsonSerializer don't work for deep-nested object hirarchies
For the serialization of Java object instances I use the Jackson Library and have built several JsonSerializers, which should individually check Player.class, Vehicle.class and Building.class and ...
2
votes
1
answer
58
views
How to serialize snake_case model fields to camelCase in django rest framework
I'm adding REST API endpoints to my existing Django application. I'm using DRF ModelSerializer. My model classes follow the pep8 naming convention and use snake_case for field names, but I need the ...
0
votes
1
answer
52
views
How to Check if an Object is Serializable at Compile-time or Runtime Using json_serializable in Flutter?
I have a question regarding the json_serializable package for Flutter.
Is there any way to check at compile-time if an object is serializable using json_serializable?
If not, is there a way to check ...
0
votes
0
answers
57
views
Java-json-jackson: How to set JsonDeserialize without access to the (abstract) class?
After learning and searching from many examples about deserialization and handling
with a property "type" often used,
(@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type"))
...
0
votes
2
answers
77
views
How to serialize properties into separate Json using System.Text.Json in C#?
I am trying to serialize and deserialize a class (say A) into Json.
The class has multiple properties (say X1, X2, X3) which are object instances (of class X) which contains large lists.
public class ...
0
votes
0
answers
31
views
fallback nested json errors to default value
I am using kotlinx-serialization.
Let soppose I have this class
@Serializable
class Settings(
val uiScale:Float=1f,
val theme:String="dark",
)
I have serialized this class to a file ...
0
votes
1
answer
50
views
Problems with C# json serialization
I am doing a program with some derived classes for a game. I have to use json serialization to save the progress of the player but when i serialize the Player class it only serialize the types of his ...
1
vote
1
answer
156
views
Delphi serializing JSON using REST.Json vs using System.JSON.Serializers
Have just downloaded Delphi 12.1 and tried out JSON Data Binding Wizard for the first time. Amongst other options it offers
JSON mapping library: JSON marshaling/serialization library, for which the ...