简体   繁体   English

如果我本地有文件,可以在主线程上解析JSON吗?

[英]Can i parse JSON on the main thread if I have the file locally

I need to know whether I will be able to read (parse) a big (1500-2500 lines) JSON if i have it in the device for offline usage and do it on the main thread? 我需要知道如果我将其存储在设备中以供离线使用并在主线程上进行操作,是否能够读取(解析)大(1500-2500行)JSON? I think it shouldnt be a problem but its only a suggestion. 我认为这不应该是一个问题,但这只是一个建议。

You can, but I wouldn't recommend it. 您可以,但我不建议您这样做。 It'll result in a pause that isn't ideal. 这将导致不理想的暂停。 It's not hard to offload that to an AsyncTask or some other means of moving it away from the main thread. 将其卸载到AsyncTask或其他将其从主线程中移出的方法并不难。

是的,可以,但是如果您执行的是大型任务,则它可能会冻结UI(取决于您要解析的生命周期状态),但作为kabuko用户,建议您在AsyncTaskAsyncTaskLoader启动另一个线程。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我可以在主线程中发出 Json Volley 请求吗? - Can i make Json Volley request in main thread? 使用Okhttp和GSON库解析JSON响应时,我在主线程异常中获取网络 - When parse a JSON response using Okhttp and GSON Library then i am getting Network on main thread exception 如何创建第二个线程,进行进度对话并暂停主线程? - How can I create a 2nd thread, have progressdialog and pause the main thread? 我可以在“活动”中包含一个主Map文件并与Fragment共享吗? - Can I have a main Map file in my Activity and share it with the Fragments? 我可以在主线程上读取一个小的txt文件,还是应该总是避免I / O? - Can I read a small txt file on the main thread or should I ALWAYS avoid I/O there? 获取 E/AndroidRuntime: FATAL EXCEPTION: main error, 我正在尝试解析 json 文件,但它抛出错误 - Getting E/AndroidRuntime: FATAL EXCEPTION: main error, I am trying to parse json file but it'ss throwing error 我可以在主线程(UI线程)之外创建UI吗? - Can I create UI outside main thread (UI Thread)? 如何解析android activity_main.xml文件并进行修改? - How can I parse android activity_main.xml file and modify it? 我有一个 json 但不知道如何解析它 - I have got a json but have no idea how to parse it 我在assets文件夹中有一个json,我想从那个文本文件中解析图像我从json解析了用户名请帮我解析一个图像 - I have a json in assets folder and i would like to parse image from that text file i parsed user names from json please help me to parse a image
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM