Como se muestra a continuación:
paquete com.unionx.wanxue; import java.util.map; import java.util.map.entry; importar net.sf.json.jsonObject; /** * Use jsonObject to map to get all key-value pairs in json* Add conditions in the loop, and you can also get specific key-value pairs* Note the lead package*/ public class test { @SuppressWarnings("unchecked") public static void main(String args[]){ JSONObject json1=JSONObject.fromObject("{'username' : '11111', 'ClientID': '', 'contraseña': '222222'} "); Map <string, object> map = json1; for (Entry <String, Object> Entry: MAP.ENTRYSET ()) {System.out.println (Entry.getKey ()+"="+Entry.getValue ()); }}}El artículo anterior Java obtiene todos los ejemplos de pares de valor clave en JSON es todo el contenido que comparto con usted. Espero que pueda darle una referencia y espero que pueda apoyar más a Wulin.com.