kotlin-jsonq alternatives and similar libraries
Based on the "JSON" category.
Alternatively, view kotlin-jsonq alternatives based on common mentions on social networks and blogs.
-
jackson-module-kotlin
Module that adds support for serialization/deserialization of Kotlin (http://kotlinlang.org) classes and data classes. -
Kotson
Gson for Kotlin, Kotson enables you to parse and write JSON with Google's Gson using a conciser and easier syntax.
WorkOS - The modern identity platform for B2B SaaS
Do you think we are missing an alternative of kotlin-jsonq or a related project?
README
kotlin-jsonq
A simple Kotlin library to Query over JSON Data
Installation
Gradle,
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
And
dependencies {
implementation 'ninja.sakib:kotlin-jsonq:v0.2'
}
Usage
Let's see a quick example:
Sample data (data.json)
{
"name": "products",
"description": "Features product list",
"vendor": {
"name": "Computer Source BD",
"email": "[email protected]",
"website": "www.example.com"
},
"users": [
{
"id": 1,
"name": "Johura Akter Sumi",
"location": "Barisal"
},
{
"id": 2,
"name": "Mehedi Hasan Nahid",
"location": "Barisal"
},
{
"id": 3,
"name": "Ariful Islam",
"location": "Barishal"
},
{
"id": 4,
"name": "Suhel Ahmed",
"location": "Sylhet"
},
{
"id": 5,
"name": "Firoz Serniabat",
"location": "Gournodi"
},
{
"id": 5,
"name": "Musa Jewel",
"location": "Barishal",
"visits": [
{
"name": "Sylhet",
"year": 2011
},
{
"name": "Cox's Bazar",
"year": 2012
},
{
"name": "Bandarbar",
"year": 2014
}
]
}
],
"products": [
{
"id": 1,
"city": "bsl",
"name": "iPhone",
"cat": 1,
"price": 80000.5
},
{
"id": 2,
"city": null,
"name": "macbook pro",
"cat": 2,
"price": 150000.1
},
{
"id": 3,
"city": "dhk",
"name": "Redmi 3S Prime",
"cat": 1,
"price": 12000.1
},
{
"id": 4,
"city": null,
"name": "Redmi 4X",
"cat": 1,
"price": 15000.1
},
{
"id": 5,
"city": "bsl",
"name": "macbook air",
"cat": 2,
"price": 110000.00
},
{
"id": 6,
"city": null,
"name": "macbook air 1",
"cat": 2,
"price": 81000.2
}
],
"cities": [
{
"id": 1,
"name": "Barishal"
},
{
"id": 2,
"name": "Noakhali"
},
{
"id": 3,
"name": "Dhaka"
},
{
"id": 4,
"name": "Rajshahi"
},
{
"id": 5,
"name": "Chittagong"
}
],
"arr": [
1,
2,
3,
4
]
}
Examples
[x] Initialization,
val inputStream = Thread.currentThread().contextClassLoader.getResourceAsStream("data.json") jsonq = JSONQ(inputStream)
[x] find,
val obj = jsonq.find("users.5.visits")
Result,
[ { "name": "Sylhet", "year": 2011 }, { "name": "Cox's Bazar", "year": 2012 }, { "name": "Bandarbar", "year": 2014 } ]
[x] whereEq,
val res = jsonq.from("users.5.visits").whereEq("name", "Bandarbar")
Result,
[ { "name": "Bandarbar", "year": 2014 } ]
[x] hasSuffix,
val res = jsonq.from("users").hasSuffix("name", "Sumi")
Result,
[ { "id": 1, "name": "Johura Akter Sumi", "location": "Barisal" } ]
[x] Query Chaining
val res = jsonq.from("users").whereGe("id", 3).whereEq("location", "Barisal").contains("name", "Is")
Result,
[ { "id": 3, "name": "Ariful Islam", "location": "Barisal" } ]
TODO
- [ ] Add missing methods
- [ ] Write full documentation with example
Bugs and Issues
If you encounter any bugs or issues, feel free to open an issue at github.
Also, you can shoot me an email to [email protected] for hugs or bugs.
Special Mention
Nahid Bin Azhar for the original idea.
Contribution
If you are interested to make the package better please send pull requests or create an issue so that others can fix. [Read the contribution guide here](CONTRIBUTING.md)
See all contributors
*Note that all licence references and agreements mentioned in the kotlin-jsonq README section above
are relevant to that project's source code only.