I am happy to see this .NET works really hard in system.Text.Json in a wider way to use it. Advantage here is : No need of external library called Newtonsoft.Json Cons: How confident we are with System.Text.Json. Whether we good to go on usage with our inbuilt library? Please let us know everyone on this and from which .net version and c# language it supports all the functionality of NewtonSoft.Json in our inbuilt library. If you give that confidence to all dotnet programmers or architects we are really happy to use it with replacement of matured Newtonsoft.Json.
Can we take the json file to deserialize into sth, Object, but we don't have that Class Template at first? Can we generate that Class along the Deserialization?
17:18 The reason it didn't hit the breakpoint is that it hit a breakpoint at the setter of the `Date` property on the WeatherForecast class. VS Code probably got confused by the breakpoint on the empty line. You just terminated the program too soon. The code was perfectly fine. `Deserialize` isn't an async method, so you didn't need the `await`. So the only "shocking" thing is that you used *non-async* file IO. Shudder /s. My best guess is that since the breakpoint was at the empty line 16, it moved the breakpoint to the first line that could have a breakpoint, which was the property at line 19. Stupid that VS Code would allow breakpoints on empty lines in the first place.
Yup, @JamesMontemagno commented to a few others and we added this small correction in the video details: Correction: 00:17:18 Async isn't actually required here, the breakpoint didn't hit due to the program executing too soon and adding the Console.WriteLine would have fixed this up, although with File IO access async operations should be considered.
And @16:58, similarly, just pass the filename to Deserialize instead of a FileStream. The FileStream should be used internally. I should not need to provide it.
I don't think you an d just pass in the file name, if you pass in just a string it will try to deserialize that string: learn.microsoft.com/en-us/dotnet/api/system.text.json.jsonserializer.deserialize?view=net-8.0
Just me following docs :), but yes an await using would also work. the using will just call Dispose, but not DisposeAsync. I made a PR: github.com/dotnet/docs/pull/38948
@@RamonDeKlein yeah. I understand that. What I don't understand is that he implied it hadn't worked on the first try, because he hadn't used async. I can't imagine that being the case. But maybe I just missed some other comments he made.
It would work either way. The main issue I ran into and couldn't' fix in edit was that I didn't have anything to break on after. So once I added the Console.WriteLine the breakpoint would have been hit. Although I would suggest async/await when handling this as it could be a very large JSON blob.
I was heading out on holiday and knew i was going to do a lot of swimming so decided it was time. It was 12" total and I donated it to a charity where they make wigs for kids and cancer patients.