これは初めてjson.netを使用しているため、わかりません。以下は私のコードです。json.netを使用してjsonを逆シリアル化できません
// Constructor
public MainPage()
{
InitializeComponent();
}
private void btnRefreshTweets_Click(object sender, RoutedEventArgs e)
{
string ServerURL = @"http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer/1/query?text=e&geometry=&geometryType=esriGeometryPoint&inSR=&spatialRel=esriSpatialRelIntersects&relationParam=&objectIds=&where=&time=&returnCountOnly=false&returnIdsOnly=false&returnGeometry=false&maxAllowableOffset=&outSR=&outFields=&f=json";
WebClient webClient = new WebClient();
webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient_DownloadStringCompleted);
webClient.DownloadStringAsync(new Uri(ServerURL));
}
void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error != null)
{
return;
}
List<Attributes> tweets = JsonConvert.DeserializeObject<List<Attributes>>(e.Result);
this.lbTweets.ItemsSource = tweets;
}
public class Attributes
{
public string STATE_NAME { get; set; }
}
STATE_NAME属性を逆シリアル化できません。私は何が欠けていますか?
私は、 " '[WPJsonSample.MainPage +属性] System.Collections.Generic.List`1' をタイプ にJSONオブジェクトをデシリアライズすることはできません。 ライン1、位置20" このエラーに
を得続けますJSONはそのURLから返さ
を吸う場合でも、固有名詞を維持することができますこの方法では、それが「displayFieldName」のように、あまりにも他のものを持っている、「fieldAliases」、「フィールドと 『機能』(あなたのjson.netと違いがあるのかどうかは分かりませんが、それらをすべて収容するオブジェクトを作成しようとしたらどうでしょうか? – blitzen
json.netに進む前にこの投稿をチェックアウトします。 //www.drowningintechnicaldebt.com/ShawnWeisfeld/archive/2010/08/22/using-c-4.0-and-dynamic-to-parse-json.aspx –