Skip to content

Commit 2f2e2aa

Browse files
committed
Updated to version 1.2.0
1 parent 8bd0a1a commit 2f2e2aa

File tree

4 files changed

+57
-6
lines changed

4 files changed

+57
-6
lines changed

README.md

+12-5
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
A JSON5 Library for Java (11+)
44

5-
*This branch contains features of the unreleased [version 1.1.0](https://github.com/json5/json5-spec/milestone/2)*
6-
75
## Overview
86

97
The [JSON5 Standard](https://json5.org/) tries to make JSON more human-readable
@@ -12,7 +10,7 @@ This is a reference implementation, capable of parsing JSON5 data according to t
1210

1311
## Getting started
1412

15-
In order to use the code, you can either [download the jar](https://github.com/Synt4xErr0r4/json5/releases/download/1.1.0/json5-1.1.0.jar), or use the Maven dependency:
13+
In order to use the code, you can either [download the jar](https://github.com/Synt4xErr0r4/json5/releases/download/1.2.0/json5-1.2.0.jar), or use the Maven dependency:
1614
```xml
1715
<!-- Repository -->
1816

@@ -26,7 +24,7 @@ In order to use the code, you can either [download the jar](https://github.com/S
2624
<dependency>
2725
<groupId>at.syntaxerror</groupId>
2826
<artifactId>json5</artifactId>
29-
<version>1.1.0</version>
27+
<version>1.2.0</version>
3028
</dependency>
3129
```
3230

@@ -113,6 +111,7 @@ Supported data types are:
113111
- `int`
114112
- `float`
115113
- `double`
114+
- `Number` (any sub-class)
116115
- `String`
117116
- `JSONObject`
118117
- `JSONArray`
@@ -121,7 +120,7 @@ Supported data types are:
121120
The normal `getXXX(String key)` and `getXXX(int index)` methods will throw an exception if the specified key or index does not exist, but the
122121
`getXXX(String key, XXX defaults)` and `getXXX(int index, XXX defaults)` methods will return the default value (parameter `defaults`) instead.
123122

124-
The `set(int index, XXX value)` method will also throw an exception if the index does not exist. You can use `add(XXX value)` instead to append a value to the list.
123+
The `set(int index, Object value)` method will also throw an exception if the index does not exist. You can use `add(Object value)` instead to append a value to the list.
125124

126125
The getter-methods for numbers always return a rounded or truncated result.
127126
If the actual number is too large to fit into the requested type, the upper bits are truncated (e.g. `int` to `byte` truncates the upper 24 bits).
@@ -161,6 +160,14 @@ The following options are currently implemented:
161160
Whether or not invalid unicode surrogate pairs should be allowed
162161
- `quoteSingle`: (default `false`, *Stringify-only*)
163162
Whether or not string should be single-quoted (`'`) instead of double-quoted (`"`). This also includes a JSONObject's member names
163+
164+
### v1.2.0
165+
166+
- added `clear()` method
167+
removes all values from an object/array
168+
- added `remove(String key)` and `remove(int index)` methods
169+
remove a certain key/index from an object/array
170+
164171
## Documentation
165172

166173
The JavaDoc for the latest version can be found [here](https://javadoc.syntaxerror.at/json5/latest).

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>at.syntaxerror</groupId>
44
<artifactId>json5</artifactId>
5-
<version>1.1.0</version>
5+
<version>1.2.0</version>
66
<packaging>jar</packaging>
77

88
<name>JSON5 for Java</name>

src/main/java/at/syntaxerror/json5/JSONArray.java

+22
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,28 @@ public int length() {
150150
return values.size();
151151
}
152152

153+
/**
154+
* Removes all values from this JSONArray
155+
*
156+
* @since 1.2.0
157+
*/
158+
public void clear() {
159+
values.clear();
160+
}
161+
162+
/**
163+
* Removes the value at an index from a JSONArray
164+
*
165+
* @param index the index to be removed
166+
* @since 1.2.0
167+
*
168+
* @throws JSONException if the index does not exist
169+
*/
170+
public void remove(int index) {
171+
checkIndex(index);
172+
values.remove(index);
173+
}
174+
153175
// -- CHECK --
154176

155177
/**

src/main/java/at/syntaxerror/json5/JSONObject.java

+22
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,28 @@ public int length() {
176176
return values.size();
177177
}
178178

179+
/**
180+
* Removes all values from this JSONObject
181+
*
182+
* @since 1.2.0
183+
*/
184+
public void clear() {
185+
values.clear();
186+
}
187+
188+
/**
189+
* Removes a key from a JSONObject
190+
*
191+
* @param key the key to be removed
192+
* @since 1.2.0
193+
*
194+
* @throws JSONException if the key does not exist
195+
*/
196+
public void remove(String key) {
197+
checkKey(key);
198+
values.remove(key);
199+
}
200+
179201
// -- CHECK --
180202

181203
/**

0 commit comments

Comments
 (0)