如下述数据,在java中如何转成json格式?
[[[{"id":0,"cont":"我","pos":"r","ne":"O"},{"id":1,"cont":"想","pos":"v","ne":"O"},{"id...
[
[
[
{
"id": 0,
"cont": "我",
"pos": "r",
"ne": "O"
},
{
"id": 1,
"cont": "想",
"pos": "v",
"ne": "O"
},
{
"id": 2,
"cont": "吃",
"pos": "v",
"ne": "O"
},
{
"id": 3,
"cont": "橘子",
"pos": "n",
"ne": "O"
},
{
"id": 4,
"cont": "。",
"pos": "wp",
"ne": "O"
}
]
]
] 展开
[
[
{
"id": 0,
"cont": "我",
"pos": "r",
"ne": "O"
},
{
"id": 1,
"cont": "想",
"pos": "v",
"ne": "O"
},
{
"id": 2,
"cont": "吃",
"pos": "v",
"ne": "O"
},
{
"id": 3,
"cont": "橘子",
"pos": "n",
"ne": "O"
},
{
"id": 4,
"cont": "。",
"pos": "wp",
"ne": "O"
}
]
]
] 展开
2个回答
展开全部
public static void main(String[] args) {
//初始化一个List
List<Province> list = new ArrayList<>();
//声明范型的实体1
Province c1 = new Province();
c1.setProvinceName("南京");
c1.setProvinceSort("1");
//声明范型的实体2
Province c2 = new Province();
c2.setProvinceName("北京");
c2.setProvinceSort("2");
//加入List中
list.add(c1);
list.add(c2);
//打印JSON格式的串
System.out.println(JSON.toJSON(list).toString());
}
[{"provinceName":"南京","provinceSort":"1"},{"provinceName":"北京","provinceSort":"2"}]
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询