Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Commit 47573b5

Browse files
committed
- Add utilities to deal with JSON arrays.
- Throw a runtime exception instead.
1 parent 3a6ddc3 commit 47573b5

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

README.md

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Simply supply the following command line parameter:```-Dfile.encoding=UTF8```
1313

1414
Dependencies
1515
------------
16-
The library is available on JCenter. The latest version is 1.1.0
16+
The library is available on JCenter. The latest version is 1.2.0
1717

1818
Replace ```{LATEST_VERSION}``` with the latest version.
1919

@@ -37,30 +37,37 @@ Tutorial
3737
**Converting an input stream to UTF-8 JSON**
3838
```java
3939
try {
40-
JSONObject json = JsonIO.toJSON(inputStream);
41-
} catch (IOException e) {}
40+
JSONObject json = JsonIO.toJson(inputStream);
41+
} catch (JsonIOException e) {}
42+
```
43+
44+
** Converting an input stream to UTF-8 JSON array**
45+
```java
46+
try {
47+
JSONArray jsonArray = JsonIO.toJsonArray(inputStream);
48+
} catch (JsonIOException e) {}
4249
```
4350

4451
**Converting a file to UTF-8 JSON**
4552
```java
4653
try {
47-
JSONObject json = JsonIO.toJSON(new File("sample_json.json"));
48-
} catch (IOException e) {}
54+
JSONObject json = JsonIO.toJson(new File("sample_json.json"));
55+
} catch (JsonIOException e) {}
4956
```
5057

5158
**Converting a string to UTF-8 JSON**
5259
```java
5360
try {
54-
JSONObject json = JsonIO.toJSON("{"text": "Some text"}");
55-
} catch (IOException e) {}
61+
JSONObject json = JsonIO.toJson("{"text": "Some text"}");
62+
} catch (JsonIOException e) {}
5663
```
5764

5865
**Converting JSON to file**
5966
```java
6067
JSONObject json = some JSON;
6168
try {
6269
JsonIO.toFile(json, new File("output.json"));
63-
} catch (IOException e) {}
70+
} catch (JsonIOException e) {}
6471
```
6572

6673
**Converting JSON to file (append to a file)**
@@ -69,15 +76,15 @@ JSONObject json = some JSON;
6976
try {
7077
JsonIO.toFile(json, new File("output.json"), true);
7178
}
72-
catch (IOException e) {}
79+
catch (JsonIOException e) {}
7380
```
7481

7582
**Converting JSON to a UTF-8 string**
7683
```java
7784
JSONObject json = some JSON;
7885
try {
7986
String jsonString = JsonIO.toString(json);
80-
} catch (IOException e) {}
87+
} catch (JsonIOException e) {}
8188
```
8289

8390
License

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright ©2018 HassieSwift621.
2+
# Copyright ©2018 HassieSwift621.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)