我如何将字符串响应转换为数组列表

How I convert string response into Array List

我正在使用 websockets,在 onMessage() 方法中,我收到了字符串形式的响应。我想将此响应存储在模型 class 中。如何将此字符串响应转换为数组列表?

[{"sender_id":"0008","created_at":"1313211849934","receiver_id":"0003","message":"second message","id":1,"chat_id":50,"type":"text"},{"sender_id":"0008","created_at":"1519211809934","receiver_id":"0003","message":"second message","id":2,"chat_id":50,"type":"text"}]
class Data {
  var sender_id:String? = null
  var created_at:String? = null
  var receiver_id:String? = null
  var message:String? = null
  var id:Int
  var chat_id:Long
  var type:String? = null
}

val jsonContent = "[{"sender_id":"0008","created_at":"1313211849934","receiver_id":"0003","message":"second message","id":1,"chat_id":50,"type":"text"},{"sender_id":"0008","created_at":"1519211809934","receiver_id":"0003","message":"second message","id":2,"chat_id":50,"type":"text"}]"
val data = new Gson().fromJson(jsonContent, Data:class.java)