forked from I2P_Developers/i2p.i2p
NDT: Prevent NPE on JSON parse of bad/empty input (ticket #2672)
This commit is contained in:
@ -29,6 +29,8 @@ public class JSONUtils {
|
|||||||
public static String getValueFromJsonObj(String jsonTxt, String key) {
|
public static String getValueFromJsonObj(String jsonTxt, String key) {
|
||||||
JSONValue jsonParser = new JSONValue();
|
JSONValue jsonParser = new JSONValue();
|
||||||
Map json = (Map)jsonParser.parse(new String(jsonTxt));
|
Map json = (Map)jsonParser.parse(new String(jsonTxt));
|
||||||
|
if (json == null)
|
||||||
|
return null;
|
||||||
Iterator iter = json.entrySet().iterator();
|
Iterator iter = json.entrySet().iterator();
|
||||||
while(iter.hasNext()){
|
while(iter.hasNext()){
|
||||||
Map.Entry entry = (Map.Entry)iter.next();
|
Map.Entry entry = (Map.Entry)iter.next();
|
||||||
|
Reference in New Issue
Block a user