首页 > 解决方案 > 从 URL 反序列化 JSON - 如何将其添加到多个对象

问题描述

所以基本上我通过jsonUtils运行 JSON,它创建了一个对象,结果证明是几个对象。

所以请教2个问题:

  1. 如何最好地从 URL 填充对象?
  2. 我可以选择要填充的对象,即我不想做所有 20 个对象吗?

先谢谢了!!

WebClient client = new WebClient();
        string myJSON = client.DownloadString("https://someURL.geojson");
        var myClass = Newtonsoft.Json.JsonConvert.DeserializeObject(myJSON);
        Console.Write(myClass.ToString());

public class PrecipType
{
public string units { get; set; }
public string value { get; set; }
}

public class Press
{
public string units { get; set; }
public string value { get; set; }
}

public class Atmo
{
public AirTemperature  air_temp{ get; set; }
public Dewpoint dew_point{ get; set; }
public Wind { get; set; }
public Pressure pressure { get; set; }
}

public class ObsTime
{
public string units { get; set; }
public string value { get; set; }
}

标签: jsoncore

解决方案


推荐阅读