Reading Invalid JSON with System.Text.Json

preview_player
Показать описание
Join James and Matt as they walk through some advanced features in System.Text.Json (STJ) on how to allow comments, trailing commas, and quoted numbers in JSON when deserializing data. We also talk through out to write numbers as strings if needed.

00:00 - Intro
01:26 - Invalid JSON Example
02:50 - Allowing Training Commands and Comments
04:15 - Reading & Writing Quoted Numbers
07:58 - Wrap-up

#dotnet #systemtextjson #json
Рекомендации по теме
Комментарии
Автор

Thanks for the video, I think this makes it easier to avoid exceptions and improves reliability.

coffeeandloot
Автор

It will be an uphill battle to get people off of Newtonsoft LOL

robl
Автор

I wonder if there are any performance impacts when turning off the strict checking.

PankajNikam
Автор

Is there an option for treating single quotes as double quotes for property names, or other string values? (I have seen this in the wild and had to resort to string.Replace...)

talwald
Автор

Given the apparent long list of possible options, it seems one would already have to know which options would be realistic candidates in a given environment. This leads me to think that an app reading the json file would be somewhat aware/knowledgeable of where the data comes from, and what format it can typically come in. One can't possibly anticipate ahead of time all the ways a json file might be wrongfully formatted.

Also, are there ways to specify what the "comment" formats are? In this example, it was using c/c++ format by default, it seems. But what if semi-columns are used, for instance?

enriquebenedicto
Автор

In a post api I send {"quantity":"xyz", "name":"peter"} and the request are null, the quantity type is decimal i cannot validate with fluentValidator , some idea?

pesfan
Автор

How to force this to be default for webapis ?

foro
Автор

What happen if i send string in a int value in that json ?

pesfan
Автор

This guy James sounds a lot like that long haired bearded guy from the MAUI videos 😉

jd
Автор

I thought the original intention of System.Text.Json was to strictly adhere to the JSON standards?

julian_b