【发布时间】:2020-03-24 16:04:51
【问题描述】:
所以我有这个字符串格式的 JSON:
[
"1.0",
"1.1",
"1.2"
]
但我需要在 Kotlin 中将其转换为 ArrayList 吗?我试图找到,但大多数答案都在 Java 中。如果在 Java 中使用 gson 可能会是这样。但我是初学者,未能将下面的代码转换为 Kotlin
Gson gson = new GsonBuilder().create();
ArrayList<String> theList = gson.fromJson(stringObject, new TypeToken<ArrayList<String>>(){}.getType())
在 Kotlin 中如何将该 json 字符串转换为数组列表?
【问题讨论】: