Рет қаралды 41,207
🚀 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