kotlin json解析(仿swiftJson)

2019-08-28  本文已影响0人  清风昕雨_f69d

需要添加json implementation 'com.fasterxml.jackson.core:jackson-databind:2.10.0.pr1'

1.基本类型 JsonParser.parse(jsonString)["num"].intValue 

2.对象 ListBean(json) 

3.list JsonParser.parse(jsonString)["list"].arrayValue.map { subJson -> ListBean(subJson) }

数据类 

class ListBean(json: Json) { 

var num:Int = json["num"].intValue 

var id :Int = json["id"].intValue

}

gitHub:https://github.com/hycinth/KotlinJson

邮箱:1093529347@qq.com

上一篇 下一篇

猜你喜欢

热点阅读