我正在使用监护人API来尝试和检索故事但仍然收到异常.json的字符串包含下面的json,但是我无法使用LINQ访问正文.
这里是:
{
"response":{
"status":"ok",
"userTier":"approved",
"total":1,
"startIndex":1,
"pageSize":10,
"currentPage":1,
"pages":1,
"orderBy":"newest",
"results":[{
"id":"sustainable-business/sustainable-finance-where-next-open-thread",
"sectionId":"sustainable-business",
"sectionName":"Guardian Sustainable Business",
"webPublicationDate":"2014-02-13T13:27:00Z",
"webTitle":"Where next for sustainable finance? - open thread",
"webUrl":"http://www.theguardian.com/sustainable-business/sustainable-finance-where-next-open-thread",
"apiUrl":"http://content.guardianapis.com/sustainable-business/sustainable-finance-where-next-open-thread",
"fields":{
"body":"<img src=\"http://hits.theguardian.com/b/ss/guardiangu-api/1/H.20.3/98867?ns=guardian&pageName=Where+next+for+sustainable+finance%3F+-+open+thread+Article+2043222&ch=Guardian+Sustainable+Business&c2=461773&c4=MIC%3A+Finance+%28GSB%29%2CMIC%3A+Guardian+Sustainable+Business%2CPRO%3A+Sustainability+%28Guardian+Professional%29&c3=theguardian.com&c6=Laura+Paddison&c7=14-Feb-13&c8=2043222&c9=Article\" width=\"1\" height=\"1\" />..."
}
}]
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试过包括这个在内的所有事情:
string story = (string)ja["response"]["results"]["fields"]["body"];
Run Code Online (Sandbox Code Playgroud)
更新:
public partial class Story : PhoneApplicationPage
{
string url;
string jsonData;
// Http used so the json can be retrived via the get async methods
HttpClient webClient = new HttpClient();
protected override void OnNavigatedTo(NavigationEventArgs e) …Run Code Online (Sandbox Code Playgroud) 我有以下方式设置课程:
public abstract FooClass {
public FooClass() {
// init stuff;
}
public void RandomMethod() {
// do stuff;
}
public abstract WhatIWantToShim();
}
Run Code Online (Sandbox Code Playgroud)
我想要做的是在ShimFooClass上设置WhatIWantToShim,如下所示:
ShimFooClass.AllInstances.WhatIWantToShim = () => Boo();
Run Code Online (Sandbox Code Playgroud)
我可以设置RandomMethod就好了,
ShimFooClass.AllInstances.RandomMethod = () => CalculatePi();
Run Code Online (Sandbox Code Playgroud)
但是,生成的ShimFooClass似乎不会在ShimFooClass的AllInstances属性上创建WhatIWantToShim属性.
我看过http://msdn.microsoft.com/en-us/library/hh549176.aspx#bkmk_shim_basics,但我没有看到任何有关抽象方法的内容.我看到的唯一不支持的是终结器.有人知道这里发生了什么,是否支持这种情况?
我想弄清楚我是否真的需要请求ACCESS_FINE_LOCATION.我不需要真正准确的坐标.但是,如果无法使用手机信号塔或WiFi,我希望能够从GPS获取位置(精度很低).但是,我在Android文档中找不到关于此的明确答案.以下是Android Docs所说的内容(ACCESS_COARSE_LOCATION).它告诉我,请求粗略位置给我提供来自"Cell-ID,WiFi"源的信息,并且请求精确许可将使用GPS,但它没有说明GPS只是粗略位置许可时的任何类型的后备请求.
public static final String ACCESS_COARSE_LOCATION
自:API级别1
允许应用程序访问粗略(例如,Cell-ID,WiFi)位置
常量值:"android.permission.ACCESS_COARSE_LOCATION"
public static final String ACCESS_FINE_LOCATION
自:API级别1
允许应用程序访问精细(例如,GPS)位置
常量值:"android.permission.ACCESS_FINE_LOCATION"