Skip to content

Commit 956f6d5

Browse files
committed
SCANJLIB-217 Replace minimal-json by gson
1 parent c2e15e9 commit 956f6d5

3 files changed

Lines changed: 13 additions & 19 deletions

File tree

lib/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
<artifactId>okhttp-urlconnection</artifactId>
2222
</dependency>
2323
<dependency>
24-
<groupId>com.eclipsesource.minimal-json</groupId>
25-
<artifactId>minimal-json</artifactId>
24+
<groupId>com.google.code.gson</groupId>
25+
<artifactId>gson</artifactId>
2626
</dependency>
2727
<dependency>
2828
<groupId>com.google.code.findbugs</groupId>

lib/src/main/java/org/sonarsource/scanner/lib/Utils.java

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,12 @@
1919
*/
2020
package org.sonarsource.scanner.lib;
2121

22-
import com.eclipsesource.json.Json;
23-
import com.eclipsesource.json.JsonObject;
24-
import com.eclipsesource.json.JsonObject.Member;
25-
import com.eclipsesource.json.JsonValue;
22+
import com.google.gson.stream.JsonReader;
2623
import java.io.File;
2724
import java.io.FileOutputStream;
2825
import java.io.IOException;
2926
import java.io.OutputStream;
27+
import java.io.StringReader;
3028
import java.nio.file.FileVisitResult;
3129
import java.nio.file.Files;
3230
import java.nio.file.Path;
@@ -49,18 +47,14 @@ public static Properties loadEnvironmentProperties(Map<String, String> env) {
4947
Properties props = new Properties();
5048

5149
if (scannerParams != null) {
52-
try {
53-
54-
JsonValue jsonValue = Json.parse(scannerParams);
55-
JsonObject jsonObject = jsonValue.asObject();
56-
Iterator<Member> it = jsonObject.iterator();
57-
58-
while (it.hasNext()) {
59-
Member member = it.next();
60-
String key = member.getName();
61-
String value = member.getValue().asString();
50+
try (JsonReader reader = new JsonReader(new StringReader(scannerParams))) {
51+
reader.beginObject();
52+
while (reader.hasNext()) {
53+
String key = reader.nextName();
54+
String value = reader.nextString();
6255
props.put(key, value);
6356
}
57+
reader.endObject();
6458
} catch (Exception e) {
6559
throw new IllegalStateException("Failed to parse JSON in SONARQUBE_SCANNER_PARAMS environment variable", e);
6660
}

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@
8080
<version>${okhttp.version}</version>
8181
</dependency>
8282
<dependency>
83-
<groupId>com.eclipsesource.minimal-json</groupId>
84-
<artifactId>minimal-json</artifactId>
85-
<version>0.9.5</version>
83+
<groupId>com.google.code.gson</groupId>
84+
<artifactId>gson</artifactId>
85+
<version>2.10.1</version>
8686
</dependency>
8787
<dependency>
8888
<groupId>com.squareup.okhttp3</groupId>

0 commit comments

Comments
 (0)