Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > .NET Frameworks (точка нет фреймворки) > C# (си шарп)
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 04.05.2018, 22:18   #1
FunnyNeo
 
Регистрация: 30.03.2017
Сообщений: 5
По умолчанию Парсинг JSON

Здравствуйте, возникли трудности с парсингом информации, которую я выгружаю со Steam API, класс для JSON есть:

Код:
  public class Info
    {
        public class PcRequirements
        {
            public string minimum { get; set; }
        }

        public class MacRequirements
        {
            public string minimum { get; set; }
        }

        public class LinuxRequirements
        {
            public string minimum { get; set; }
        }

        public class PriceOverview
        {
            public string currency { get; set; }
            public int initial { get; set; }
            public int final { get; set; }
            public int discount_percent { get; set; }
        }

        public class Sub
        {
            public int packageid { get; set; }
            public string percent_savings_text { get; set; }
            public int percent_savings { get; set; }
            public string option_text { get; set; }
            public string option_description { get; set; }
            public string can_get_free_license { get; set; }
            public bool is_free_license { get; set; }
            public int price_in_cents_with_discount { get; set; }
        }

        public class PackageGroup
        {
            public string name { get; set; }
            public string title { get; set; }
            public string description { get; set; }
            public string selection_text { get; set; }
            public string save_text { get; set; }
            public int display_type { get; set; }
            public string is_recurring_subscription { get; set; }
            public List<Sub> subs { get; set; }
        }

        public class Platforms
        {
            public bool windows { get; set; }
            public bool mac { get; set; }
            public bool linux { get; set; }
        }

        public class Metacritic
        {
            public int score { get; set; }
            public string url { get; set; }
        }

        public class Category
        {
            public int id { get; set; }
            public string description { get; set; }
        }

        public class Genre
        {
            public string id { get; set; }
            public string description { get; set; }
        }

        public class Screenshot
        {
            public int id { get; set; }
            public string path_thumbnail { get; set; }
            public string path_full { get; set; }
        }

        public class Recommendations
        {
            public int total { get; set; }
        }

        public class Achievements
        {
            public int total { get; set; }
        }

        public class ReleaseDate
        {
            public bool coming_soon { get; set; }
            public string date { get; set; }
        }

        public class SupportInfo
        {
            public string url { get; set; }
            public string email { get; set; }
        }

        public class Data
        {
            public string type { get; set; }
            public string name { get; set; }
            public int steam_appid { get; set; }
            public int required_age { get; set; }
            public bool is_free { get; set; }
            public string detailed_description { get; set; }
            public string about_the_game { get; set; }
            public string short_description { get; set; }
            public string supported_languages { get; set; }
            public string header_image { get; set; }
            public object website { get; set; }
            public PcRequirements pc_requirements { get; set; }
            public MacRequirements mac_requirements { get; set; }
            public LinuxRequirements linux_requirements { get; set; }
            public List<string> developers { get; set; }
            public List<string> publishers { get; set; }
            public PriceOverview price_overview { get; set; }
            public List<int> packages { get; set; }
            public List<PackageGroup> package_groups { get; set; }
            public Platforms platforms { get; set; }
            public Metacritic metacritic { get; set; }
            public List<Category> categories { get; set; }
            public List<Genre> genres { get; set; }
            public List<Screenshot> screenshots { get; set; }
            public Recommendations recommendations { get; set; }
            public Achievements achievements { get; set; }
            public ReleaseDate release_date { get; set; }
            public SupportInfo support_info { get; set; }
            public string background { get; set; }
        }

        public class __invalid_type__10
        {
            public bool success { get; set; }
            public Data data { get; set; }
        }

        public class RootObject
        {
            public __invalid_type__10 __invalid_name__10 { get; set; }
        }

Так же собственно сам Get запрос
Код:
 public class ApiService
    {
        private const String API_URL = @"http://store.steampowered.com/api/appdetails?appids=";

        public String GetGameById(long id)
        {
            String url = API_URL + id;
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            request.AutomaticDecompression = DecompressionMethods.GZip;
            String json;
            using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
            using (Stream stream = response.GetResponseStream())
            using (StreamReader reader = new StreamReader(stream))
            json = reader.ReadToEnd();
            return json;

        }
    
    }
Заранее благодарен.
FunnyNeo вне форума Ответить с цитированием
Старый 04.05.2018, 22:23   #2
FunnyNeo
 
Регистрация: 30.03.2017
Сообщений: 5
По умолчанию

Забыл добавить Main (выгружается по id 10, т.е игра Counter - Strike).
Код:
 static void Main(string[] args)
        {
            ApiService gameService = new ApiService();
            String json = gameService.GetGameById(10);
            Console.WriteLine(json);
            Console.Read();
        }
FunnyNeo вне форума Ответить с цитированием
Старый 05.05.2018, 11:28   #3
pu4koff
Старожил
 
Аватар для pu4koff
 
Регистрация: 22.05.2007
Сообщений: 9,520
По умолчанию

и в чём собственно трудности? вижу скачивание строки, парсинг json не вижу.
pu4koff вне форума Ответить с цитированием
Старый 23.09.2022, 13:07   #4
robertjames
Новичок
Джуниор
 
Регистрация: 23.09.2022
Сообщений: 1
По умолчанию

/currencies.json wll be used where JSON is the list of all currency symbols available from the Open Exchange Rates API, along with their full names, for use in your integration. This list will always mirror the currencies available in the latest rates (given as their 3-letter codes).

Even I have an experience of using Forex Crypto Stock , helps me a lot to understand the conversions of currency in an easy manner.
robertjames вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц

Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск


Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Парсинг JSON istory Общие вопросы Delphi 0 28.11.2017 19:16
Парсинг JSON и вывод token ffirstal4 Общие вопросы Delphi 6 22.08.2017 12:16
Парсинг string в БД. json. c# zink Общие вопросы .NET 1 05.06.2016 10:02
Парсинг JSON. (X-SuperObject) Delphi XE8 mailkyda Общие вопросы Web 1 23.05.2016 07:13
Парсинг массива в json C_R_E_S_C_H Общие вопросы Delphi 0 12.05.2012 23:39