1

我在发送 JSON Feed 请求时遇到了这个问题。问题是提要有一个动态标题(即,当我发送对“testinput1”的请求时,标题响应将是 testinput1.

因此,我需要使我的 RootObject 动态化,但我不确定如何,请您帮帮我吗?

我已经输入了下面代码的麻烦部分

Deployment.Current.Dispatcher.BeginInvoke(() =>
{
    textBlock1.Text = "Details Loaded.";
    short_description.Text = feed.testinput1.short_description; // can I make testinput1 a constant? its based on code below
});

public class Event
{
    public string description { get; set; }
    public string datetime { get; set; }
}

public class TrackCode
{
    public string short_description { get; set; }
    public List<Event> events { get; set; }
}

public class RootObject
{
    public string tracker;
    public TrackCode testinput1// This needs to be based on user input each time
    {
        get; // Can I do something here to make sure that the "testinput1" changes each time?
        set;  // And create a constant that can be referred to?
    }
}

希望我能做这样的事情:

     short_description.Text = feed.trackcode.short_description; // this is a constant


    public class RootObject
    {
        public string tracker = "AB123456789NZ"; // This is the variable that changes

        public TrackCode trackcode // this becomes a constant
        {
            get { return tracker; }  // uses tracking number as value for JSON when it retrieves it
            set { tracker = value;}
        }
    }

我哪里出错了?谢谢!

4

0 回答 0