Serialize and Deserialize Json to C# [Step By Step Tutorial of JSON in C#]

  Рет қаралды 47,419

Coding Droplets

Coding Droplets

Күн бұрын

Пікірлер: 40
@gdelfino
@gdelfino 3 жыл бұрын
Thank you for the video. There are many JSON / C# videos out there but yours is the only one that I found that explains the usage of the JsonProperty attribute.
@CodingDroplets
@CodingDroplets 3 жыл бұрын
Glad to hear that!
@pushpakchintu656
@pushpakchintu656 Жыл бұрын
Can anyone please send me proper video.. which you have seen... Serialisation and. Deserialization with example
@teftele
@teftele Жыл бұрын
Especially thanks for DateTime constructor explaining😊
@CodingDroplets
@CodingDroplets Жыл бұрын
Thank you for your comment! I'm glad that you found the explanation of the DateTime constructor helpful.
@CodingDroplets
@CodingDroplets 3 жыл бұрын
Hello everyone! Thanks for watching this video. We have started a new tutorial series on .Net Blazor . Check it out now: kzbin.info/aero/PLzewa6pjbr3IQEUfNiK2SROQC1NuKl6PV Follow on Twitter: twitter.com/codingdroplets
@teftele
@teftele Жыл бұрын
Level Up! 🎉 I adore json😅
@CodingDroplets
@CodingDroplets Жыл бұрын
Thank you for your comment! I'm glad to hear that you enjoyed the tutorial and that you have an appreciation for JSON. It's a versatile and widely used data format that has become integral to modern web development.
@narennd9258
@narennd9258 2 жыл бұрын
Very useful and simple example to understand easily
@CodingDroplets
@CodingDroplets 2 жыл бұрын
Glad you think so!
@itorres008
@itorres008 2 жыл бұрын
Thanks for the video. It would have been useful to demonstrate reading a .JSON text file and deserializing and then serializing and writing back to a text file, instead of doing the copy/paste for the examples. Showing the reading and writing to file would teach an essential operation for this to be applied.
@CodingDroplets
@CodingDroplets 2 жыл бұрын
You are most welcome! Thank you for you valuable suggestion. I'm planning to do another video which explains all about JSON and I'll include reading and writing JSON content to a file as well. Once again thank you for the support.
@hemanthreddyveluri8563
@hemanthreddyveluri8563 Жыл бұрын
@@CodingDroplets Is that video posted? If yes, please post that video link/URL here. It would be very helpful :)
@tinashechinyati6823
@tinashechinyati6823 2 жыл бұрын
This is GOLD, Thank you so much for this clear explanation. Do you have any courses I can follow to learn C#?🙂
@CodingDroplets
@CodingDroplets 2 жыл бұрын
Most Welcome! Thank you for your valuable feedback. All videos in our channel are for C# developers.
@roshanikolhe3870
@roshanikolhe3870 Жыл бұрын
This was helpful
@CodingDroplets
@CodingDroplets Жыл бұрын
Thank you!
@solomonmuwori1954
@solomonmuwori1954 2 жыл бұрын
Thanks so much. Have a question though. How does one populate a C# class that has a One-To-Many structure and serialize. An example is an invoice having a Header and Detail lines. HEADER attributes (CustomerId, Date, InvoiceNo). DETAIL lines attributes (StockItem, Quantity, Amount). The Detail lines will be a List of items bought subordinate to the Invoice Header.
@CodingDroplets
@CodingDroplets 2 жыл бұрын
From the details you mentioned, I hope you need the model class structures like below. You need to create three model classes. public class Invoice { public InvoiceHeader Header { get; set; } public List Details { get; set; } } public class InvoiceHeader { public string CustomerId { get; set; } public DateTime InvoiceDate { get; set; } public string InvoiceNumber { get; set; } } public class InvoiceDetail { public string StockItem { get; set; } public decimal Quantity { get; set; } public decimal Amount { get; set; } } The InvoiceHeader and InvoiceDetail model classes are used in the main Invoice model class. So you can just create the object of Invoice model class and populate the data. Rest of the processes are same for serialization and deserialization. You can just serialize the Invoice model class object to generate JSON string. Same JSON string can be deserialized back to Invoice model class object.
@solomonmuwori1954
@solomonmuwori1954 2 жыл бұрын
@@CodingDroplets Thanks very much for being responsive. What I am looking for is a loop in C# that will load data into the InvoiceDetail so I can serialize the Invoice which is the composite object.
@CodingDroplets
@CodingDroplets 2 жыл бұрын
Most welcome! As you told, you can loop through the items to populate InvoiceDetail list. Please refer the below video links. You can achieve it using Lambda expressions. kzbin.info/www/bejne/fpOoYWp-oMSbb9U Also you can make use of normal for loops. kzbin.info/www/bejne/jYbXhGRqfdKXiq8
@solomonmuwori1954
@solomonmuwori1954 2 жыл бұрын
Thanks very much
@CodingDroplets
@CodingDroplets 2 жыл бұрын
Most welcome!
@chris5947
@chris5947 Жыл бұрын
Thank you for this tutorial, very well explained.
@CodingDroplets
@CodingDroplets Жыл бұрын
Glad it was helpful!
@aJ-4T7
@aJ-4T7 Жыл бұрын
How would you display deserialised objects for readability
@CodingDroplets
@CodingDroplets Жыл бұрын
Thank you for your question! How you choose to display deserialized objects depends on the context and requirements of your application. If you need to display the data in JSON format, you can simply serialize the object back to a JSON string with formatting for readability.
@aJ-4T7
@aJ-4T7 Жыл бұрын
I have a heavily nested object- 4 levels deep. I want to display it in a readable format. I also want the ability to export it to a .csv
@kausainshaikh1999
@kausainshaikh1999 Жыл бұрын
How to add/delete buttons using JSON file in UI ?
@onlysimran
@onlysimran 3 жыл бұрын
After getting json data in object, how can we iterate over it and find particular value
@CodingDroplets
@CodingDroplets 3 жыл бұрын
Are you deserializing to array/list of objects? If yes, you can use normal for loops to iterate.
@sundarraaj2944
@sundarraaj2944 2 жыл бұрын
How to do serialisation for complex nested JSON?
@CodingDroplets
@CodingDroplets 2 жыл бұрын
I hope you are having arrays or lists in your model class. You can serialize using the same 'JsonConvert.Serialize' method. Can you share your model class content?
@sundarraaj2944
@sundarraaj2944 2 жыл бұрын
s I have an array and a nested array .
@CodingDroplets
@CodingDroplets 2 жыл бұрын
You can serialize using the same 'JsonConvert.Serialize' method as explained in the video. Please let me know if you find any difficulties.
@APB-r7k
@APB-r7k 2 жыл бұрын
Dude the whole point of doing serialization and deserialization is to create a jsob text file and you didn't do that
@CodingDroplets
@CodingDroplets Жыл бұрын
Sorry for that. Once the serialization is done, we can just use System.IO.File.WriteAllText method to write to a file.
@pushpakchintu656
@pushpakchintu656 Жыл бұрын
Can anyone please send me proper video.. which you have seen... Serialisation and. Deserialization with example
@oscarenbacka_4909
@oscarenbacka_4909 2 жыл бұрын
how did you paste it to the notepad at 8.00
@CodingDroplets
@CodingDroplets Жыл бұрын
Hope you got it
JSON IN C# - Downloading Data and Making Objects From It
24:10
tutorialsEU
Рет қаралды 41 М.
Using JSON IN C#! Serialization & Deserialization made easy!
14:47
tutorialsEU - C#
Рет қаралды 35 М.
I was just passing by
00:10
Artem Ivashin
Рет қаралды 18 МЛН
When Cucumbers Meet PVC Pipe The Results Are Wild! 🤭
00:44
Crafty Buddy
Рет қаралды 63 МЛН
How Many Balloons To Make A Store Fly?
00:22
MrBeast
Рет қаралды 170 МЛН
C# JSON Deserialization | Serialization and Deserialization| Nested Json #4
12:18
Binary Automation - SDETs
Рет қаралды 17 М.
Learn JSON in 10 Minutes
12:00
Web Dev Simplified
Рет қаралды 3,2 МЛН
Deserialize JSON Data to Custom C# Class Objects using Newtonsoft.
26:37
Software Nuggets
Рет қаралды 21 М.
JSON support gets a major missing feature in .NET 7
9:53
Nick Chapsas
Рет қаралды 50 М.
This Is Why Python Data Classes Are Awesome
22:19
ArjanCodes
Рет қаралды 817 М.
Learn JSON Step-by-Step from Scratch
13:11
Automation Step by Step
Рет қаралды 110 М.
C# JSON Serialization | Serialization and Deserialization| Nested Json  #5
8:03
Binary Automation - SDETs
Рет қаралды 10 М.
I was just passing by
00:10
Artem Ivashin
Рет қаралды 18 МЛН