Kotlin convert json string to list of object using Gson

后端 未结 2 1686
隐瞒了意图╮
隐瞒了意图╮ 2021-02-20 17:04

I have a problem with Kotlin to write code for conversion from JSON String to List of objects.

Normally in Java, it is like this:

  Gson gson = new Gson(         


        
2条回答
  •  北恋
    北恋 (楼主)
    2021-02-20 17:22

    Try this, it uses object instead of Type..

    measurements : List = gson.fromJson(text, object : TypeToken>() {}.type) 
    

提交回复
热议问题