0

我们的 webclient 有一个 post 方法。当我尝试使用它的链接访问这个方法时,我得到了这个 json 文件:

{"user":   
{"userID":0,"username":null,"password":null,"email":null,"telephone":null,"firstName":null,
"lastName":null,"dateOfBirth":null,"street":null,"number":null,"zipcode":null,"city":null,                                            
"showPosition":false,"notificationEmail":false,"profielFoto":null,"deelnames":null,
"kosten":null,"trips":null,"enabled":true,"authorities":  
[{"authority":"ROLE_USER"}],"accountNonLocked":true,"accountNonExpired":true,"credentialsNonExpired":true}}

但是我需要将此 JSON 文件转换为:

{"userID":0,"username":null,"password":null,"email":null,"telephone":null,"firstName":null,
"lastName":null,"dateOfBirth":null,"street":null,"number":null,"zipcode":null,"city":null,                                            
"showPosition":false,"notificationEmail":false,"profielFoto":null,"deelnames":null,
"kosten":null,"trips":null,"enabled":true,"authorities":  
[{"authority":"ROLE_USER"}],"accountNonLocked":true,"accountNonExpired":true,"credentialsNonExpired":true}

所以没有第一行。

我怎样才能做到这一点?

谢谢

4

1 回答 1

0
JSONObject jo = new JSONObject(yourJsonString);
JSONObject user = jo.get("user");

如果您需要将其作为字符串,

user.toString();

使用http://jsonviewer.stack.hu/更好地了解您的 JSON 对象。

于 2013-03-08T14:30:03.503 回答