Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to search JSON files? [closed]

Tags:

json

xcode

ios

I am writing an application that read its data in JSON format. It is supposed to be a classified ads app. For example it fetches the list of categories, the sub-categories and each ad from separate JSON files. Now i want to add a search option. The problem is that i do not know if it is possible to search through the JSON files and if it is efficient. Does anyone have a better way of doing this?

like image 845
Rashid Avatar asked Dec 10 '25 23:12

Rashid


1 Answers

If you're trying to avoid using a database, you only have a couple options. Load them into memory (up front or lazily). That has the benefit of making it much faster at the cost of memory footprint (space vs time). But in your comments, you said that uses to much memory. The other option is to load and unload every JSON document every time. But if you were worried about the memory footprint due to the number of documents, this will likely be too slow. There's a variant where you could create your own homegrown index but at that point, you're starting to create your own database.

So, in the end, it sounds like you're working to hard trying to avoid using a database.

Consider CoreData or SqlLite.

If you want to work with simple JSON documents, also consider EJDB which is an embedded JSON document based document db (like MongoDb). There is also an objective-c wrapper for EJDB known as EJDBKit.

It aims to be a fast MongoDB-like library which can be embedded into C/C++, .Net, NodeJS, Python, Lua, Go, Java and Ruby applications under terms of LGPL license.

EJDB is the C library based on modified version of Tokyo Cabinet.

JSON representation of queries and data implemented with API based on C BSON

like image 72
bryanmac Avatar answered Dec 12 '25 13:12

bryanmac