Skip to content

Commit b8c0b33

Browse files
authored
Update README.md
1 parent e9fb80c commit b8c0b33

File tree

1 file changed

+32
-22
lines changed

1 file changed

+32
-22
lines changed

README.md

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,10 @@
44

55
This package is inspired from the awesome [jsonq](https://github.com/nahid/jsonq) package.
66

7-
### Installation
8-
9-
Gradle,
10-
```gradle
11-
allprojects {
12-
repositories {
13-
...
14-
maven { url "https://jitpack.io" }
15-
}
16-
}
17-
```
18-
And
19-
```gradle
20-
dependencies {
21-
implementation 'com.github.shuza:kt-jsonq:v0.1'
22-
}
23-
```
24-
257
# Usage
268
You can start using this package right away by importing your Json data from a file:
279
```kotlin
28-
val inputStream = FileInputStream(FILE_PATH)
29-
val jsonQ = JsonQ(inputStream)
10+
val jsonQ = JsonQ("data.json")
3011
```
3112
You 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.
3213

@@ -109,6 +90,34 @@ println(result)
10990
*/
11091
341000
11192
```
93+
It has reactive programming support. Let's see some example
94+
```kotlin
95+
jsonq.from("users")
96+
.whereLess("id", 3)
97+
.rxGet()
98+
.subscribe(object : SingleObserver<JsonArray> {
99+
override fun onSuccess(t: JsonArray) {
100+
println(t)
101+
}
102+
103+
override fun onSubscribe(d: Disposable) {}
104+
105+
override fun onError(e: Throwable) {
106+
println(e.message)
107+
}
108+
})
109+
110+
/**** It will print ******/
111+
[{
112+
"id": 1,
113+
"name": "Johura Akter Sumi",
114+
"location": "Barisal"
115+
}, {
116+
"id": 2,
117+
"name": "Mehedi Hasan Nahid",
118+
"location": "Barisal"
119+
}]
120+
```
112121
cool, huh?
113122

114123
Let's explore the full API to see what else magic this library can do for you. Shall we?
@@ -128,8 +137,9 @@ Following API examples are shown based on the sample JSON data given [here](http
128137
* [whereStartsWith]()
129138
* [whereEndsWith]()
130139
* [whereContains]()
131-
* [orWhereEq]()
132-
* [andWhereEq]()
140+
* [or]()
141+
* [and]()
142+
* [rx]()
133143
* [get]()
134144
* [sum]()
135145
* [max]()

0 commit comments

Comments
 (0)