[英]Parsing a JSON Result with exhaustive list
Good day, i am trying to parse this JSONObject returned from the OpenWeatherMap forecast API. 美好的一天,我正在尝试解析从OpenWeatherMap预报API返回的JSONObject。 this is the link link here
这是这里的链接
now it returns an exhaustive list of results and i just want to get the results for each day at rough 12:00 with the key "dt_txt". 现在,它返回了详尽的结果列表,我只想使用“ dt_txt”键在大约12:00每天获取每天的结果。 i was thinking of something like parsing only the dates and comparing with a date method that increments the current day in a loop and if it matches, i then parse the values for that day.
我正在考虑只解析日期,然后与日期方法进行比较的方法,该方法将循环增加当前日期,如果匹配,则解析该天的值。 But i wanted to know if there is a better, faster and more efficient solution to achieve this.
但是我想知道是否有更好,更快和更有效的解决方案来实现这一目标。 Many thanks.
非常感谢。
Have you tested how long a simple new JSONObject(textFromYourLink)
takes? 您是否测试了一个简单的
new JSONObject(textFromYourLink)
需要多长时间? Is it even necessary to optimize the speed? 甚至有必要优化速度吗?
If there is actually, some need for optimization, I'd suggest that you do some pre-processing of the text and, using some regular expressions, get rid of the parts you don't need. 如果确实存在一些优化需求,我建议您对文本进行一些预处理,并使用一些正则表达式来摆脱不需要的部分。 After that, you still can convert the remaining string to a
JSONObject
which should be done faster now. 之后,您仍然可以将剩余的字符串转换为
JSONObject
,现在应该更快地完成此操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.