JSON IN C# - Downloading Data and Making Objects From It
Вставка
- Опубліковано 15 лип 2021
- 🚀 Master C# and .NET programming EASILY with our best-selling C# Masterclass: bit.ly/47Hk3u7
JSON IN C# - Downloading Data and Making Objects From It
A common question for developers is how to use JSON in C#. Here, we'll dive into downloading data and making objects from it!
We will be using the Newtonsoft library that can easily import JSON data into a .NET object. This tutorial covers both parsing an existing file as well as reading live data from a URL.
JSON stands for JavaScript Object Notation.
which is an open standard file format and data interchange format that uses human-readable text to store and transmit data objects.
The power of JSON is that we can convert strings into objects in any programming language and vice versa (convert objects to strings). which we can then send over the network or store locally to retrieve later.
A JSON object has the following format..
Our Curly brackets will contain the data of our JSON.
Then we write down the Key or the name of the variable, in this case name.
Then we add :
Followed by the value of the key (name) in this case it’s “Sif”.
And if we have more data we can add them separated by a comma ‘,’ followed by the key-value pairs.
In C# this JSON object will translate into an object with two properties, a name and age.
Then when we convert this JSON object or string into a player object we can deal with it as we normally use any C# object.
But how do we convert JSON to C# objects and vice versa? For that we use Serialization and Deserialization.
tutorialsEU offers you free video tutorials about programming and development for complete beginners up to experienced programmers.
This includes C#, Unity, Python, Android, Kotlin, Machine Learning, etc.
Stay tuned and subscribe to tutorialsEU: goo.gl/rBFh3x
🚀Master C# and .NET programming EASILY with our best-selling C# Masterclass: bit.ly/47Hk3u7
Good tutorial and helpful. Just wanted to add that VS2019 has a native function to convert JSON to C# classes built-in the IDE, just copy the the JSON and go to Edit> Paste Special> "Paste JSON as Classes" and it will convert the copied JSON into C# classes no matter how complex and paste it. Also you can do the same with XML.
A this comment just saved tons of time.
This is super valuable feedback. We are working on a video, that does exactly that!
Wow! That is insanely useful, I was just about to start typing out like 6 classes all with lots of attributes thinking there has to be an easier way of doing this lol. Thanks so much
That json2csharp converter was all I needed. I just finished create a super complex set of classes for a project. If only I had know. Thanks.
Thank you! Been stuck on a problem for a bit, and the JSON to C# converter helped me visualize where I was going wrong so I could fix my JSON structure.
This video was amazing thank you for actually explaining the process and not just coding it
The best video I have seen on Deserialization of JSON in C#
Thank you. I couldn't figure this problem out for a while and this video is exactly what I needed.
Great and simple explanation, thank you!
Excellent explanation, Thank you!
great demo. Thank you
Thank you so much, this is really helpful!!
Beautiful. Thanks a lot
Thank you, that was very useful.
Best json tut I have seen
Ótima explicação!
You are a life saver man
Very helpful. Thank you.
Very Useful thanks and continu the how to create local json server tutorial
thanks ,it was helpfull,and how to download multiple images from json to display in listview or any view.
I love this channel
very good job
great stuff!
thanks for the video
This tutorial had some information, however the way things are explained are only applicable when it's setup this exact way. It would be nice to know how to modify, change things for different circumstances because the likely hood of coding in this exact method will probably not be high.
awesome.
great stuff, you should make it so that lets say these JSON object can be stored in a database, how one can achieve that
謝謝!
Thank you very much!
Can you tell me any suggestions on my first Android App ? Its available on Playstore. App name World of C++
Dsrk souls references?
Thank you Dark Souls.
You are a star... thank you so much Really appreciate it. Thanks
wow c# makes stuff so complicated compared to javascript lol.
Newtonsoft library severely degrade the application performance as it uses the reflection when deserialization big data.
IMO, you should have used system.text.json. it's a built-in package and has more features and fast than newsoftjson...
Working on a new video for that. thanks for your feedback.