0
這是JSON代碼我的Java代碼中添加Java數據,如何使用JSON解析
package favr.com.example2;
public class Final {
public Result1 result;
public Infor info;
Final(Result1 result,Infor info)
{
this.result=result;
this.info=info;
}
class Result1 {
String gender;
UserName user;
Location1 location1;
public Result1(String gender, UserName user, Location1 location1) {
this.gender = gender;
this.user = user;
this.location1 = location1;
}
private class UserName {
String title;
String first;
String last;
public UserName(String title, String first, String last) {
this.title = title;
this.first = first;
this.last = last;
}
}
private class Location1 {
String street;
String city;
String state;
public Location1(String street, String city, String state) {
this.street = street;
this.city = city;
this.state = state;
}
}
}
class Infor {
String seed;
int results;
int page;
public Infor(String seed, int results, int page) {
this.seed = seed;
this.results = results;
this.page = page;
}
}
}
JSON代碼:
{
results:[
gender:"female",
user:[
title:"qwe",firstname:"dev" ,lastname:"java"
],
location:[
street:"abc",city:"def",state:"xyz"
]
]
info:[
seed:"abcdef",page:"1234",result:"1"
]
}
現在我想的名字性別和其他附加價值字段使用json解析 我怎麼能通過這個。我試圖在stackoverflow鏈接上搜索,但他們顯示了使用java訪問json代碼。 謝謝
請說明一下:您試圖解決什麼問題?你期望輸出什麼?你試過什麼了? – BPS
首先,我已經做了這個java類,現在我想在這個對象中添加值,比如使用json數據的地址和位置。我應該使用哪些代碼? @BPS – devjava20