Skip to content

Commit

Permalink
parse JSON strictly
Browse files Browse the repository at this point in the history
  • Loading branch information
esaulpaugh committed Dec 16, 2022
1 parent 275ee3f commit c18c9ff
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/main/java/com/esaulpaugh/headlong/abi/util/JsonUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,18 @@
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonPrimitive;
import com.google.gson.internal.Streams;
import com.google.gson.stream.JsonReader;

import java.io.StringReader;

public final class JsonUtils {

private JsonUtils() {}

@SuppressWarnings("deprecation")
public static JsonElement parseElement(String json) {
return new JsonParser().parse(json); // JsonParser.parseString(json);
return Streams.parse(new JsonReader(new StringReader(json)));
}

public static JsonObject parseObject(String json) {
Expand Down

0 comments on commit c18c9ff

Please sign in to comment.