0

1) I need to download a large JSON file on a Windows Phone application, I would like to process the JSON as it is downloading, because otherwise the app just keeps downloading the JSON and this can take up to 10 seconds or more, is there any way to do this? I have searched for this for 2 days now and nothing seems to be working...

2) Is there any easy way to check for new items in this JSON file? It's hosted online so I would have to check if there are new items (nodes) added to the file.

4

2 回答 2

1
  1. 只需询问服务器是否有新内容,让他向您发送实际的新内容。它将少得多,因此在线传输的数据更少,处理和可视化(如果需要)它的时间也更少。

  2. 或者创建 JSON 请求,获取数据包中的数据,并在每个数据包到达后进行处理。下载需要更长的时间,因为在处理过程中您会阻止请求,但它会向用户提供反馈。您可以利用这一点,通过在本地 JS 堆栈中推送数据包并继续请求另一个数据包,同时处理在其之上已经可用的数据包。但是对于这个足够简单(在我看来)的东西,它变得相当复杂,imo。

于 2013-06-24T20:24:45.017 回答
0

1.如果要逐步解析JSON对象,请查看JSON.NET的JsonReader.

请注意,在 Windows Phone 上,您无法从 UI 线程上的网络流中取数据,但如果您将工作推送到后台线程(请参阅BackgroundWorker),则可以。

2. 如果您的网络服务器支持它,您可以传递一个If-None-Match/If-Modified-Since标头并接受 304 响应以表明没有任何改变。

但是,这只匹配整个 HTTP 请求。如果您需要更详细的信息,您可以将您的请求拆分为:

a) 请求 ID 列表和最后修改日期

b) 请求 ID 列表的详细信息(由应用根据修改日期确定)

于 2013-06-25T03:00:52.403 回答