fix JsonUtils to handle null

This commit is contained in:
Grahame Grieve 2020-02-12 17:45:32 +11:00
parent 977026e62e
commit 6ea5016da5
1 changed files with 2 additions and 1 deletions

View File

@ -28,6 +28,7 @@ import java.util.Map.Entry;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
public class JSONUtil {
@ -73,7 +74,7 @@ public class JSONUtil {
public static String str(JsonObject json, String name) {
JsonElement e = json.get(name);
return e == null ? null : e.getAsString();
return e == null || e instanceof JsonNull ? null : e.getAsString();
}
public static String str(JsonObject json, String name1, String name2) {