是否有一个json简单函数从jsonobject获取所有键?

时间:2019-05-09 16:32:59

标签: java json-simple

我第一次尝试在Java上使用jsonsimple库。 所以我用一个字符串格式化了一个json对象。 对象如下

{
   "mario":{
   "city": "rome",
   "birth": 1980,
  "haircolor": "blonde"
  },
"Lucas": {
  "city": "milan",
  "birth": 1985,
  "haircolor": "brown"
   }
}

我需要从这些对象中获取String格式的名称。 谢谢大家的帮助。

1 个答案:

答案 0 :(得分:0)

JsonObject实现了java.util.Map,因此您只需在JsonObject上调用keySet-Method

示例:

wget --save-cookies cookies.txt \
     --keep-session-cookies \
     --post-data 'user=xxxxx&password=yyyyyy' \
     --delete-after \
     https://login.microsoftonline.com/whoumcprod.onmicrosoft.com/oauth2/authorize?client_id=bb2a2e3a-c5e7-4f0a-88e0-8e01fd3fc1f4&redirect_uri=https%3a%2f%2flogin.microsoftonline.com%2fte%2fwhoumcprod.onmicrosoft.com%2foauth2%2fauthresp&response_type=id_token&scope=email+openid&response_mode=query&nonce=J78c93S8nwGNYe5GH%2fHm8w%3d%3d&nux=1&nca=1&domain_hint=whoumcprod.onmicrosoft.com&mkt=en-US&lc=1033&state=StateProperties%3deyJTSUQiOiJ4LW1zLWNwaW0tcmM6NGY5NWRjMDAtNWFlMi00ZDEwLWE5NWEtZDZhODNkZjRjMjY4IiwiVElEIjoiNDk4NGQ5ODYtYTg1Zi00NWE2LWJlYWYtODU4MTk4Y2Y2MDVhIn0

wget --load-cookies cookies.txt \
     https://downloadarea.who-umc.org/