1//Program.cs2using System;3using System.Net.Http;4using Newtonsoft.Json;567namespace EEW
8{9 class Program
10{11staticvoidMain(string[] args)12{13 var url = $"https://api.iedred7584.com/eew/json/";14 var client = new HttpClient();15 var json = client.GetStringAsync(url).Result;16 var eew = JsonConvert.DeserializeObject<EEW>(json);17 var 取得結果 = eew.ParseStatus;18 var 予報or警報 = eew.Title;19 Console.WriteLine("ここだよー"+ 予報or警報);202122}23}24}
C#
1//EEW.cs2using System;3using System.Collections.Generic;4using System.Text;56namespace EEW
7{8 public class EEW
9{10 public string ParseStatus { get; set;}11 public string Title { get; set;}//ここどうすればいいのでしょうか。1213}14}
namespace NewtonsoftJson
// ・・・中略・・・
public class EarthQuake // Rootobject から変更
{
public string ParseStatus { get; set; }
public Title Title { get; set; }
public Source Source { get; set; }
public Status Status { get; set; }
public Announcedtime AnnouncedTime { get; set; }
public Origintime OriginTime { get; set; }
public string EventID { get; set; }
public Type Type { get; set; }
public int Serial { get; set; }
public Hypocenter Hypocenter { get; set; }
public Maxintensity MaxIntensity { get; set; }
public bool Warn { get; set; }
public Option Option { get; set; }
public string OriginalText { get; set; }
}
public class Title
{
public int Code { get; set; }
public string String { get; set; }
public string Detail { get; set; }
}
public class Source
{
public int Code { get; set; }
public string String { get; set; }
}
public class Status
{
public string Code { get; set; }
public string String { get; set; }
public string Detail { get; set; }
}
public class Announcedtime
{
public string String { get; set; }
public int UnixTime { get; set; }
public string RFC1123 { get; set; }
}
public class Origintime
{
public string String { get; set; }
public int UnixTime { get; set; }
public string RFC1123 { get; set; }
}
public class Type
{
public int Code { get; set; }
public string String { get; set; }
public string Detail { get; set; }
}
public class Hypocenter
{
public int Code { get; set; }
public string Name { get; set; }
public bool isAssumption { get; set; }
public Location Location { get; set; }
public Magnitude Magnitude { get; set; }
public Accuracy Accuracy { get; set; }
public bool isSea { get; set; }
}
public class Location
{
public float Lat { get; set; }
public float Long { get; set; }
public Depth Depth { get; set; }
}
public class Depth
{
public int Int { get; set; }
public string String { get; set; }
}
public class Magnitude
{
public float Float { get; set; }
public string String { get; set; }
public string LongString { get; set; }
}
public class Accuracy
{
public Epicenter Epicenter { get; set; }
public Depth1 Depth { get; set; }
public Magnitude1 Magnitude { get; set; }
public int NumberOfMagnitudeCalculation { get; set; }
}
public class Epicenter
{
public int Code { get; set; }
public string String { get; set; }
public int Rank2 { get; set; }
public string String2 { get; set; }
}
public class Depth1
{
public int Code { get; set; }
public string String { get; set; }
}
public class Magnitude1
{
public int Code { get; set; }
public string String { get; set; }
}
public class Maxintensity
{
public string From { get; set; }
public string To { get; set; }
public string String { get; set; }
public string LongString { get; set; }
}
public class Option
{
public Change Change { get; set; }
}
public class Change
{
public int Code { get; set; }
public string String { get; set; }
public Reason Reason { get; set; }
}
public class Reason
{
public int Code { get; set; }
public string String { get; set; }
}
}