赞
踩
- import com.fasterxml.jackson.databind.ObjectMapper;
-
- import java.util.ArrayList;
- import java.util.List;
-
- public class Main {
- public static void main(String[] args) throws Exception {
- // 创建一个包含字符串的List
- List<String> list = new ArrayList<>();
- list.add("item1");
- list.add("item2");
- list.add("item3");
-
- // 将List转换成JSON字符串
- ObjectMapper objectMapper = new ObjectMapper();
- String json = objectMapper.writeValueAsString(list);
-
- System.out.println(json);
- }
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。