Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.HashMap; public class Main { public static boolean asBoolean(Object node, String key) { return asBoolean(node, key, false); } public static boolean asBoolean(Object node, String key, boolean def) { Object value; if ((node instanceof HashMap<?, ?>) && ((value = ((HashMap<?, ?>) node).get(key)) != null)) { if (value instanceof Boolean) { return ((Boolean) value).booleanValue(); } else { return Boolean.valueOf(value.toString()); } } else { return def; } } }