Taking Json Data

Hi friends, in this writing, I will talk about how to draw Json Data. First of all, Jason, we need to know why. Json is actually a data format created for JavaScript. Prior to Json, methods such as xml were used, but over time, these data types became heavy and inconvenient, along with Json data types. Json is short. The long form is JavaScript Object Notation, which means JavaScript object representation.

If we say where and how to use this json data, this is the answer; you will use it everywhere. For example, you are writing a project. In this project, we have both the web side and the mobile side as well as the Windows Form. You will work with the data in the project you are developing. One of the easiest ways to show and transfer this data is to work with Json. Of course, you also need to communicate with a web service. In my previous article, I talked about web service development with Asp.Net Core. Here too, the data returned in Json data format. You can find that article here.

In this article, I will talk about how you can project the data returned by this web service in this Json data type in any application. In case I am an example, I will draw data from the Console. Of course this should be an example for this. I will use Json data here as an example. But you can also use the data that you created yourself.

We are opening our console project. The first thing we do here is to load a package to make it easier to do transactions with Json data. This package is Newtonsoft.Json package.

We will receive the data after adding the package, but once we receive this data, we need to associate it with a type, a model. We need to create a model for this from the future model. As an example we have a very easy method to use if you say how to create for the data on the site. We will copy all the text on the site, and you can create a model for any data string from another nice site, Json2csharp. The model for the site where I left the link is like below.

After he wrote a model for the future, he got the model to work. We need to write an administrator for this. After creating a class we need to create HttpClient. After creating this client we need to specify what type we will work with. We specify this because we will work with json data. Now we need to tell in which Url we should not withdraw the data. After you specify the client, we read the data in this field as a string. After reading this data, we integrate the data properly into our model with the package that we added first. As a last step, I return this data in the form of a list. What we need to be aware of here is that functions are asynchronous. On this count, we can do it in the back of the process and expect to have to wait for the data to be pulled.

Finally, we have not shown this data on the Console. After you take the data, you can easily display it. You can see how many pieces of data are in the photo and a sample data.

If you have any questions, please feel free to mail or comment me.

6 thoughts on “Taking Json Data

  1. Merhabalar öncelikle,
    Hocam benim sorunum; ben internet üzerinden json uzantılı dosyadaki verileri (id,başlık,detay,url …) gibi kategoriler şeklinde ayrıştırmak istiyorum ama yapamadım, çeşitli makalelere bakarak bunu denedim olmuyor, ama internet üzerindeki json dosyasının verilerini kopyalayıp benim bilgisayarda local e kaydettikten sonra onları rahatlıkla çekebiliyorum ama internet üzerindeki json uzantısını çekemiyorum, size zahmet olmazsa bir ornek üzerinden açıklayabilir misiniz?

  2. Hocam selamlar;
    Xamarin programlamayı öğrenmeye çalışıyorum.
    Web servislerimi oluşturdum ve postman ya da doğrudan explorerdan erişebiliyorum.
    Normal desktop .Net uygulamasından da erişebiliyorum ama iş xamarin e gelince bir türlü başaramadım.
    Rica etsem bu örneğinizin kaynak kodlarını paylaşabilir misiniz?

  3. c# form üzerine; token ile korunmuş, internet üzerindeki json verileri nasıl alabilirim. token kodu var. json verileride apide mevcut. yardımcı olabilir misiniz

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.