Skip to main content

All Questions

Tagged with
16 votes
1 answer
18k views

asp .net core 6 how to update option for json serialization. Date format in Json serialization

My apologies for the silly question, but I don't see a good example of how can I specify a specific format for DateTime in JSON serialization for .net core 6. The old way, net core 3. // in the ...
Sergii Zhuravskyi's user avatar
5 votes
1 answer
3k views

How to deserialize part of json using System.Text.Json in .net core 3.0?

I have a json from here https://api.nasa.gov/insight_weather/?api_key=DEMO_KEY&feedtype=json&ver=1.0 which looks like: { "782": { "First_UTC": "2021-02-06T17:08:...
Galina Melnik's user avatar
1 vote
1 answer
131 views

Passing json through a controller

I have this back-end system that produces json. Is it possible to pass that data through a controller on request and correctly setting the mimetype? Everything I've tried so far tries to re-serialize ...
Jurgy's user avatar
  • 2,270
1 vote
2 answers
3k views

.Net Core 3.0 object Type set value

I'm trying to build my .net core 3.0 web api project but stuck on a statement last 4 days. Here is my problem. I have a filtration model called "GridFilter" this model looks like this : public ...
Ersin Devrim's user avatar
1 vote
1 answer
2k views

Custom JsonConverter attributes not working with Json.Serialize() using Newtonsoft.JSON in ASP.NET Core 3.1

I want to use Newtonsoft Json.NET to perform de/serialization in an ASP.NET Core 3.1 application. I've put the following in my startup ConfigureServices code: services.AddMvc().AddNewtonsoftJson(); ...
zola25's user avatar
  • 1,871
4 votes
1 answer
2k views

JsonSerializer Struct with asp-net core 3.0

I'm having issues with .net core 3.0 when I convert a struct to a json. (with wasn't a problem when I was using .net core 2.2) This is my struct [Serializable] struct Item { public int A; ...
gabriela-moreira's user avatar
12 votes
2 answers
6k views

JsonOutputFormatter in ASP.NET Core 3.0

In asp.net core 2.2 I used to have the following, var jsonSettings = new JsonSerializerSettings { ContractResolver = new SubstituteNullWithEmptyStringContractResolver() }; services.AddMvc(...
Michael Esteves's user avatar
25 votes
1 answer
20k views

Modifying a JSON file using System.Text.Json

I know you can do this easily with Newtonsoft. As I am working with .NET Core 3.0, however, I am trying to use the new methods for interacting with JSON files —i.e., System.Text.Json—and I refuse to ...
Louis Miles's user avatar
1 vote
1 answer
825 views

Deserializing JSON to DateTime property throws exception

I'm trying to deserialize the following JSON: { "Anriss": "SomeAnriss", "ArtikelId": 123123, "Image": null, "KanalId": 101, "MediumName": "SomeMediumName", "PublikationsDatum":...
xeraphim's user avatar
  • 4,575
0 votes
1 answer
32 views

Can I use an variable in the [Route("x/{id}") of ASP.net core 3.0?

I'm making an Customers dashboard. In this dashboard each customer has one or more contacts. Those contacts have there own screen. To get acces to that screen I thought I would Implement a route with ...
Pimminator's user avatar
0 votes
1 answer
3k views

Error when deserializing to ProblemDetails with System.Text.Json.JsonSerializer. .Net Core 3.0

Consider the following json: { "title": "SOME TITEL", "status": 500, "detail": "Some detail", "errors": [ { "Parameter": "SOME VALUE", "Code": "SOME ...
Diego's user avatar
  • 746
2 votes
2 answers
714 views

ASP.NET 3.0. Date in seconds cannot be converted from JSON to System.Date within POST request

I want to test my POST endpoint with simple request with JSON in its body. I have an ASP.NET Core 3.0 project with one single controller and one endpoint inside it. I created empty ASP.NET Core ...
Ghost's user avatar
  • 33
8 votes
3 answers
8k views

JsonIgnore attribute keeps serializing properties in ASP.NET Core 3

I've recently updated my API project to ASP.NET Core 3. Since then, [JsonIgnore] attributes are not working: public class Diagnostico { [JsonIgnore] public int TipoDiagnostico { get; set; } ...
mattinsalto's user avatar
  • 2,286
2 votes
2 answers
4k views

Json.Net JsonConstructor attribute alternative for System.Text.Json

In Json.Net we have JsonConstructor attribute in order to instruct deserializer that should use the constructor to create the object. Is there alternative in System.Text.Json?
Nikola Yankov's user avatar
123 votes
6 answers
173k views

How to set json serializer settings in asp.net core 3?

json serializer settings for legacy asp.net core applications were set by adding AddMvc().AddJsonOptions(), but I don't use AddMvc() in asp.net core 3. So how can I set global json serialization ...
Alex Zaitsev's user avatar
  • 2,726

15 30 50 per page