{"id":22266387,"url":"https://github.com/shuza/kt-jsonq","last_synced_at":"2025-10-19T08:53:32.435Z","repository":{"id":91589239,"uuid":"134777200","full_name":"shuza/kt-jsonq","owner":"shuza","description":"A simple Kotlin Library to Query over Json Data","archived":false,"fork":false,"pushed_at":"2024-03-24T21:28:37.000Z","size":103,"stargazers_count":32,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-03-24T22:38:28.170Z","etag":null,"topics":["json","json-data","json-manager","kotlin"],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shuza.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-05-24T23:03:34.000Z","updated_at":"2024-03-24T21:28:40.000Z","dependencies_parsed_at":"2024-03-30T15:33:28.388Z","dependency_job_id":null,"html_url":"https://github.com/shuza/kt-jsonq","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuza%2Fkt-jsonq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuza%2Fkt-jsonq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuza%2Fkt-jsonq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuza%2Fkt-jsonq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shuza","download_url":"https://codeload.github.com/shuza/kt-jsonq/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227895732,"owners_count":17836464,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["json","json-data","json-manager","kotlin"],"created_at":"2024-12-03T10:18:36.933Z","updated_at":"2025-10-19T08:53:32.332Z","avatar_url":"https://github.com/shuza.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"Kt-JsonQ\n===============\n[![](https://jitpack.io/v/ninja.sakib/kotlin-jsonq.svg)](https://jitpack.io/#shuza/kt-jsonq/v0.2)\n\n**kt-jsonq** is a simple, elegant kotlin library to Query over any type of JSON Data. It'll make your life easier by giving the flavour of an ORM-like query on your JSON.\n\nThis package is inspired from the awesome [jsonq](https://github.com/nahid/jsonq) package.\n\n\n\nGradle,\n```gradle\nallprojects {\n    repositories {\n        ...\n        maven { url \"https://jitpack.io\" }\n    }\n}\n```\nAnd\n```gradle\ndependencies {\n    implementation 'com.github.shuza:kt-jsonq:v1.0'\n}\n```\n\n# Usage\nYou can start using this package right away by importing your Json data from a file:\n```kotlin\nval filePath = \"data.json\"\nval inputStream = FileInputStream(filePath)\nval jsonq = JsonQ(inputStream)\n```\nYou can start Query your data using the various query methods such as **whereEq**, **whereNull**, **whereLess**, **whereStartsWith**, **orWhereNotNull**, **orWhereGreater**, **andWhereGreaterEq**, **andWhereEndsWith** and so on. Also you can aggregate your data after query using **sum**, **max**, **min** etc.\n\nLet's see a quick example:\n\n```kotlin\n//  data.json\n{\n\t\"name\": \"products\",\n\t\"description\": \"Features product list\",\n\t\"vendor\":{\n\t\t\"name\": \"Computer Source BD\",\n\t\t\"email\": \"info@example.com\",\n\t\t\"website\":\"www.example.com\"\n\t},\n\t\"users\":[\n\t\t{\"id\":1, \"name\":\"Johura Akter Sumi\", \"location\": \"Barisal\"},\n\t\t{\"id\":2, \"name\":\"Mehedi Hasan Nahid\", \"location\": \"Barisal\"},\n\t\t{\"id\":3, \"name\":\"Ariful Islam\", \"location\": \"Barisal\"},\n\t\t{\"id\":4, \"name\":\"Suhel Ahmed\", \"location\": \"Sylhet\"},\n\t\t{\"id\":5, \"name\":\"Firoz Serniabat\", \"location\": \"Gournodi\"},\n\t\t{\"id\":6, \"name\":\"Musa Jewel\", \"location\": \"Barisal\", \"visits\": [\n\t\t\t{\"name\": \"Sylhet\", \"year\": 2011},\n\t\t\t{\"name\": \"Cox's Bazar\", \"year\": 2012},\n\t\t\t{\"name\": \"Bandarbar\", \"year\": 2014}\n\t\t]}\n\t],\n\t\"products\": [\n\t\t{\"id\":1, \"user_id\": 2, \"city\": \"bsl\", \"name\":\"iPhone\", \"cat\":1, \"price\": 80000},\n\t\t{\"id\":2, \"user_id\": 2, \"city\": null, \"name\":\"macbook pro\", \"cat\": 2, \"price\": 150000},\n\t\t{\"id\":3, \"user_id\": 2, \"city\": \"dhk\", \"name\":\"Redmi 3S Prime\", \"cat\": 1, \"price\": 12000},\n\t\t{\"id\":4, \"user_id\": 1, \"city\": null, \"name\":\"Redmi 4X\", \"cat\":1, \"price\": 15000},\n\t\t{\"id\":5, \"user_id\": 1, \"city\": \"bsl\", \"name\":\"macbook air\", \"cat\": 2, \"price\": 110000},\n\t\t{\"id\":6, \"user_id\": 2, \"city\": null, \"name\":\"macbook air 1\", \"cat\": 2, \"price\": 81000}\n\t]\n}\n```\nNow let's do some query in this json data\n```kotlin\nval result = jsonQ.from(\"products\")\n            .whereEq(\"cat\", 2)\n            .build()\nprintln(result)\n\n/**\n******** This will print\n**/\n[{\n\t\"id\": 2,\n\t\"user_id\": 2,\n\t\"city\": null,\n\t\"name\": \"macbook pro\",\n\t\"cat\": 2,\n\t\"price\": 150000\n}, {\n\t\"id\": 5,\n\t\"user_id\": 1,\n\t\"city\": \"bsl\",\n\t\"name\": \"macbook air\",\n\t\"cat\": 2,\n\t\"price\": 110000\n}, {\n\t\"id\": 6,\n\t\"user_id\": 2,\n\t\"city\": null,\n\t\"name\": \"macbook air 1\",\n\t\"cat\": 2,\n\t\"price\": 81000\n}]\n```\nLet's say we want to get the Summation of price of the Queried result. We can do it easily by calling the **sum()** method instead of **get()**\n```kotlin\nval result = jsonQ.from(\"products\")\n            .whereEq(\"cat\", 2)\n\t    .build()\n            .sum(\"price\")\nprintln(result)\n\n/**\n**********  It will print\n*/\n341000\n```\nIt has reactive programming support. Let's see some example\n```kotlin\njsonq.from(\"products\")\n            .whereLess(\"id\", 3)\n\t    .build()\n            .rxSum(\"price\")\n            .subscribe(object : SingleObserver\u003cDouble\u003e {\n                override fun onSuccess(t: Double) {\n                    println(t)\n                }\n\n                override fun onSubscribe(d: Disposable) {}\n\n                override fun onError(e: Throwable) {\n                    println(e.message)\n                }\n            })\n\n/****   It will print   ******/\n433150.0\n```\ncool, huh?\n\nLet's explore the full API to see what else magic this library can do for you. Shall we?\n\n# API\nFollowing API examples are shown based on the sample JSON data given [here](https://github.com/shuza/kt-jsonq/blob/master/data.json). To get a better idea of the examples see that JSON data first. Also detailed examples of each API can be found [upcoming]().\n\n**List of API:**\n* [whereEq]()\n* [whereNotEq]()\n* [whereNull]()\n* [whereNotNull]()\n* [whereLess]()\n* [whereLessEq]()\n* [whereGreater]()\n* [whereGreaterEq]()\n* [whereStartsWith]()\n* [whereEndsWith]()\n* [whereContains]()\n* [or]()\n* [and]()\n* [rx]()\n* [get]()\n* [sum]()\n* [max]()\n* [min]()\n* [avg]()\n* [count]()\n\n## Buds and Issues\nIf you encounter any bugs or issues, feel free to [open an issue at\ngithub](https://github.com/shuza/kt-jsonq/issues).\n\nAlso, you can shoot me an email to\n\u003cmailto:shuza.sa@gmail.com\u003e for hugs or bugs.\n\n## Credit\n\nSpeical thanks to [Nahid Bin Azhar](https://github.com/nahid) for the inspiration and guidance for the package.\n\n## Contributions\n\nIf your PR is successfully merged to this project, feel free to add yourself in the list of contributors.\nSee all the [contributors](CONTRIBUTORS.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshuza%2Fkt-jsonq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshuza%2Fkt-jsonq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshuza%2Fkt-jsonq/lists"}