2013-03-08 29 views
0

我們的webclient具有post方法。當我嘗試使用它的鏈接來訪問這個方法我得到這個JSON文件:來自POST方法的JSON文件android

{"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} 

所以沒有第一線。

我該怎麼做?

感謝

+1

通過提取JSON對象中名爲「user」的JSON對象,您有? – 2013-03-08 14:27:25

回答

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

如果需要,作爲一個字符串,

user.toString(); 

使用http://jsonviewer.stack.hu/以更好地瞭解您的JSON對象。