json字符串怎么转化成java对象
展开全部
import net.sf.json.JSONObject;
public class JsonTest {
public static void main(String[] args) {
String str = "{\"lendperson\":\"李四\",\"lendcompany\":\"有限公司\",\"checkperson\":\"李四\",\"lenddate\":\"2010-07-19T00:00:00\",\"lendcounts\":4,\"" +
"passports\":[{\"passportid\":\"d\",\"name\":\"李豫川\",\"passporttype\":\"K\"},{\"passportid\":\"K9051\",\"name\":\"李平\",\"passporttype\":\"K\"}," +
"{\"passportid\":\"K90517\",\"name\":\"袁寒梅\",\"passporttype\":\"K\"},{\"passportid\":\"K905199\",\"name\":\"贺明\",\"passporttype\":\"K\"}]}";
JSONObject j = JSONObject.fromObject(str);
System.out.println(j.get("lendperson"));
}
}
public class JsonTest {
public static void main(String[] args) {
String str = "{\"lendperson\":\"李四\",\"lendcompany\":\"有限公司\",\"checkperson\":\"李四\",\"lenddate\":\"2010-07-19T00:00:00\",\"lendcounts\":4,\"" +
"passports\":[{\"passportid\":\"d\",\"name\":\"李豫川\",\"passporttype\":\"K\"},{\"passportid\":\"K9051\",\"name\":\"李平\",\"passporttype\":\"K\"}," +
"{\"passportid\":\"K90517\",\"name\":\"袁寒梅\",\"passporttype\":\"K\"},{\"passportid\":\"K905199\",\"name\":\"贺明\",\"passporttype\":\"K\"}]}";
JSONObject j = JSONObject.fromObject(str);
System.out.println(j.get("lendperson"));
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询