Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
1 vote
2 answers
26 views

How to set a JsonSerializerOptions globally for my httpClient.GetFromJsonAsync<T> calls

In my ASP.NET web API I have httpClient which call GetFromJsonAsync: var jsonSerializerOptions = new JsonSerializerOptions { PropertyNameCaseInsensitive = true, }; ...
Nicolas's user avatar
  • 6,404
0 votes
0 answers
14 views

Serialization Issues?

I create a .NET dataset in my web api that has the following schema when I perform a DataSet.GetXmlSchema: <xs:element name="Table2"> <xs:complexType> ...
SuperSavior's user avatar
0 votes
0 answers
17 views

System.Net.Http.Json is not taking Fields into account when serializing or deserializing to JSON [duplicate]

When trying to Serialize a model which has data stored in fields System.Net.Http.Json is outputting an empty JSON Object. It works only when I use property with getters and setters. I tried looking ...
Jai dewani's user avatar
0 votes
0 answers
28 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 ...
Ilya Chernomordik's user avatar
1 vote
1 answer
34 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:\...
rory.ap's user avatar
  • 34.9k
0 votes
2 answers
132 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 ...
user2138149's user avatar
0 votes
1 answer
64 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 ...
Alp's user avatar
  • 51
0 votes
0 answers
67 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....
csharpforevermore's user avatar
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" : &...
mburm's user avatar
  • 1,493
0 votes
2 answers
102 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, ... } ... } ...
Manuelarte's user avatar
  • 1,772
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 ...
Jonas's user avatar
  • 45
2 votes
1 answer
68 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 ...
Geekmard's user avatar
  • 324
0 votes
1 answer
54 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 ...
pitazzo's user avatar
  • 1,212
0 votes
0 answers
59 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")) ...
JörgH's user avatar
  • 1
0 votes
2 answers
81 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 ...
ShankarBUS's user avatar

15 30 50 per page
1
2 3 4 5
461