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