如何处理大JSON响应

时间:2023-01-05 16:56:27

I'm doing a simple iphone app, but the client sends me an 1.6mb JSON file, The client doesn't want to do any more in the backend, so I need an efficient way to handle this data, the data is going to be used later for filtering and searching inside the app.

我正在做一个简单的iphone应用程序,但是客户端发给我一个1.6mb的JSON文件,客户端不希望在后端再做任何事情,所以我需要一种有效的方法来处理这些数据,数据将会发送到稍后用于在应用程序内过滤和搜索。

What would you thing is the best way to handle this.

你最重要的是解决这个问题。

Thanks in advance

提前致谢

Update

This JSON in memory is around 4.85mb, do you guys think that is too much for an NSDictionary.

内存中的这个JSON大约是4.85mb,你们认为这对于NSDictionary来说太过分了。

1 个解决方案

#1


7  

Parse the JSON data into a Core Data store, using hashes to determine if a record is new or exists and needs updating. Use of threading for this step will make the app more responsive. You can then efficiently apply predicates (i.e., filter and search) on the data store.

将JSON数据解析为Core Data存储,使用散列来确定记录是新的还是存在的并且需要更新。在此步骤中使用线程将使应用程序更具响应性。然后,您可以在数据存储上有效地应用谓词(即过滤和搜索)。

Also, some libraries/frameworks exist to handle the JSON to Core Data mapping such as RestKit. But keep in mind it's also pretty easy to do it yourself if you don't need a generalized solution.

此外,还存在一些库/框架来处理JSON到Core Data映射,例如RestKit。但请记住,如果您不需要通用解决方案,也可以自己轻松完成。

#1


7  

Parse the JSON data into a Core Data store, using hashes to determine if a record is new or exists and needs updating. Use of threading for this step will make the app more responsive. You can then efficiently apply predicates (i.e., filter and search) on the data store.

将JSON数据解析为Core Data存储,使用散列来确定记录是新的还是存在的并且需要更新。在此步骤中使用线程将使应用程序更具响应性。然后,您可以在数据存储上有效地应用谓词(即过滤和搜索)。

Also, some libraries/frameworks exist to handle the JSON to Core Data mapping such as RestKit. But keep in mind it's also pretty easy to do it yourself if you don't need a generalized solution.

此外,还存在一些库/框架来处理JSON到Core Data映射,例如RestKit。但请记住,如果您不需要通用解决方案,也可以自己轻松完成。