来自POST方法android的JSON文件

时间:2013-03-08 14:24:41

标签: json

我们的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}

所以没有第一行。

我该怎么做?

感谢

1 个答案:

答案 0 :(得分:0)

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

如果您需要它作为字符串,

user.toString();

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