Java将看起来像数组的字符串转换为字符串数组或字符串ArrayList

大卫

我有一个看起来像数组的字符串:

["944", "The name", "Hi, hi", 1, 6, 0, false, "the date"]

注意:上面的内容包装在中",就像String一样。因此,整数和布尔值都在此String中,而像“ 944”这样的整数和布尔值也都在String中,如果愿意,也可以在String中。

如何将其设置为Java字符串数组或字符串数​​组列表?

大卫

我用Gson解决了。

Type listType = new TypeToken<List<String>>() {}.getType();
List<String> postData = new Gson().fromJson(stringThatLooksLikeArray, listType);

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章