All Questions
90
questions
1
vote
1
answer
41
views
ASP.NET Core 6 Web API : use queryString on complex json can not bind successfully
When I use the GET API to send a complex JSON format, the backend cannot obtain the data correctly.
This my query string data:
{
"page": 1,
"page_size": 10,
"...
1
vote
1
answer
122
views
.NET 6 - Type Agnostic Json Serialization with camelCase through PropertyNamingPolicy
I need a way to read json config via an asp.net 6 backend and send it to frontend in json format with camelCase property names. The original json config uses PascalCasing for its property names. The ...
1
vote
1
answer
253
views
How to ignore empty strings in API JSON response?
I have an API developed in .NET6. Currently, all properties that are being returned as null, are being hidden via the below:
_ = services.AddControllers().AddJsonOptions(options => {
options....
1
vote
1
answer
253
views
Deserialize JSON from request body with dynamic keys
I have a Rest API that accepts a JSON model consisting of its fields are dynamic GUIDs.
I tried multiple models and in all of them, I got an error.
This is the JSON:
{
"meta_data": {
...
0
votes
0
answers
108
views
Refit.ApiException at System.Text.Json.Serialization.JsonCollectionConverter
I am using Refit to call APIs in .NET 7.0
System.Text.Json.Serialization.JsonCollectionConverter throws exception when the response returned in empty.
It works fine when result contains data.
I think ...
0
votes
2
answers
106
views
.NET 6 Service: how to pass JSON inside JSON?
I am developing a .NET 6 web service (with Startup), one of methods is
public async Task<ActionResult> PutDirector([FromBody] Director director, CancellationToken cancellationToken)
{
var ...
0
votes
1
answer
2k
views
Returning Data from ASP.NET Core 6 Web API controller slow performance
We've have an ASP.NET Core 6 Web API project C#, which we originally upgraded from ASP.NET Core 3.1. We are currently having an issue where any APIs with
return new JsonResult(data)
It is incredibly ...
0
votes
1
answer
1k
views
System.Text.Json UTF-8 Deserialization confusion
I have a generic JSON file caching service that will take a .NET object and write it as default/typical minified JSON to the disk. While this works nicely, I wanted to try improving this a bit, by ...
3
votes
2
answers
2k
views
System.Text.Json JsonStringEnumConverter with custom fallback in case of deserialization failures
I have a .NET 6 program that needs to deserialize a JSON string value (returned by external API) into a .NET enum.
The issue is that there are over 100 possible enum values (and more could be added ...
0
votes
1
answer
442
views
Deserialize a JSON string received from an online API
I have a JSON feed which I am trying to deserialize:
{
"d": [
{
"__type": "Status:http://jdlf.com.au/ns/business/api",
"...
0
votes
1
answer
1k
views
How to ignore JsonPropertyName in serialization using System.Text.Json in .Net 6
I am using System.Text.Json in .NET 6 and I have some data classes that have properties annotated with JsonPropertyName to be able to communicate with another API, but now I need to use the original ...
1
vote
1
answer
106
views
Idiom for removing a JsonNode?
I am trying to modify an in memory JsonNode instance. Minimal reproducible code is simply (.NET Fiddle):
string jsonString =
@"{
""Date"": ""...
0
votes
1
answer
517
views
JSON serialization with and without private properties
There is a book class with public and private properties:
public class Book
{
private int ID { get; set; } = -1;
private string? BaseName { get; set; } = null;
public string? Title { get; ...
0
votes
2
answers
167
views
why are properties in my response object set to null?
I have this endpoint method:
var authToken = await [url]
.AddAuthHeaders(config)
.PostJsonAsync(new AuthTokenRequest
{
...
0
votes
1
answer
221
views
How to return JSON string as an sub-object in a .NET 6 WebApi controller?
I have the following data structure which I want to return as result from a controller:
public class DataModel
{
public string Id { get; private set; }
public string Name { get; private set; }...