Skip to content

Commit cb2a3b7

Browse files
committed
update README
1 parent dea22cc commit cb2a3b7

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

README.md

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,40 +12,49 @@ Here is a quick show off, for more complete report you can checkout the full [be
1212

1313
![java1](http://jsoniter.com/benchmarks/java1.png)
1414

15-
# 1 Minute Tutorial
15+
# Bind-API is the best
1616

17-
Given this JSON document `[0,1,2,3]`
17+
Bind-api should always be the first choice. Given this JSON document `[0,1,2,3]`
1818

1919
Parse with Java bind-api
2020

2121
```java
22-
import com.jsoniter.JsonIterator;
22+
import com.jsoniter.Jsoniter;
2323
Jsoniter iter = Jsoniter.parse("[0,1,2,3]");
2424
int[] val = iter.read(int[].class);
2525
System.out.println(val[3]);
2626
```
2727

28-
Parse with Java any-api
28+
# Iterator-API for quick extraction
2929

30-
```java
31-
import com.jsoniter.JsonIterator;
32-
Jsoniter iter = Jsoniter.parse("[0,1,2,3]");
33-
Any val = iter.readAny();
34-
System.out.println(any.get(3));
35-
```
30+
When you do not need to get all the data back, just extract some.
3631

3732
Parse with Java iterator-api
3833

3934
```java
40-
import com.jsoniter.JsonIterator;
41-
Jsoniter iter = Jsoniter.parse("[0,1,2,3]");
42-
int total = 0;
35+
import com.jsoniter.Jsoniter;
36+
Jsoniter iter = Jsoniter.parse("[0, [1, 2], [3, 4], 5]");
37+
int count = 0;
4338
while(iter.readArray()) {
44-
total += iter.readInt();
39+
iter.skip();
40+
count++;
4541
}
46-
System.out.println(total);
42+
System.out.println(count); // 4
43+
```
44+
45+
# Any-API for maximum flexibility
46+
47+
Parse with Java any-api
48+
49+
```java
50+
import com.jsoniter.Jsoniter;
51+
Jsoniter iter = Jsoniter.parse("[{'field1':'11','field2':'12'},{'field1':'21','field2':'22'}]".replace('\'', '"'));
52+
Any val = iter.readAny();
53+
System.out.println(val.toInt(1, "field2")); // 22
4754
```
4855

56+
Notice you can extract from nested data structure, and convert any type to the type to you want.
57+
4958
# How to get
5059

5160
```

0 commit comments

Comments
 (0)