[
{source:0,target:4,relation:"籍贯",value:1.3},
{source:4,target:5,relation:"舍友",value:1},
{source:4,target:6,relation:"舍友",value:1},
{source:4,target:7,relation:"舍友",value:1},
{source:1,target:6,relation:"籍贯",value:2},
{source:2,target:5,relation:"籍贯",value:0.9},
{source:3,target:7,relation:"籍贯",value:1},
{source:5,target:6,relation:"同学",value:1.6},
{source:6,target:7,relation:"朋友",value:0.7},
{source:6,target:8,relation:"职责",value:2}
]
添加依赖
net.sf.json-lib
json-lib
2.4
jdk15
String string = " [\n" +
" {source:0,target:4,relation:\"籍贯\",value:1.3},\n" +
" {source:4,target:5,relation:\"舍友\",value:1},\n" +
" {source:4,target:6,relation:\"舍友\",value:1},\n" +
" {source:4,target:7,relation:\"舍友\",value:1},\n" +
" {source:1,target:6,relation:\"籍贯\",value:2},\n" +
" {source:2,target:5,relation:\"籍贯\",value:0.9},\n" +
" {source:3,target:7,relation:\"籍贯\",value:1},\n" +
" {source:5,target:6,relation:\"同学\",value:1.6},\n" +
" {source:6,target:7,relation:\"朋友\",value:0.7},\n" +
" {source:6,target:8,relation:\"职责\",value:2}\n" +
"]";
JSONArray jsonArray = JSONArray.fromObject(string);