首页 > 编程知识 正文

json list格式,怎么把list转成json

时间:2023-05-06 18:46:32 阅读:48372 作者:2018

将json字符串转换为Java数组

隐私保护JSON=' {' address' :' chian', ' birthday' : {' birthday' 3360 } birthday}

@Test

公共void read JSON 2阵列(

try {

json='[' json '];

JSON array=JSON array.from object (JSON );

Object[] os=jsonArray.toArray (;

Student[] stus=(Student[] ) JSONArray.toArray(JSONArray,Student.class );

}catch(exceptione ) {

e .打印堆栈跟踪(;

}

}

执行结果如下

=========jsonarrystringjavaarray====================

#%%%{'address':'chian ',' birthday ' : { ' birthday ' : ' 2010-11-22 ' },' email'3360'email}

1

{'address':'chian ',' birthday ' : { ' birthday ' : ' 2010-11-22 ' },' email':'email@123.} .

{'address':'chian ',' birthday ' : { ' birthday ' : ' 2010-11-22 ' },' email':'email@123.} .

1

将JSON字符串转换为Java的列表集合

隐私保护JSON=' {' address' :' chian', ' birthday' : {' birthday' 3360 } birthday}

公共void read JSON2list (

try {

json='[' json '];

JSON array=JSON array.from object (JSON );

列表列表=JSON array.to list (JSON array,Student.class );

list=JSON array.to list (JSON array;

}catch(exceptione ) {

e .打印堆栈跟踪(;

}

}

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。