val fidsjson = """
{ "msg": "success", "code": "00", "result": [{ "fgId": 205, "fgIndex": 1, "fgType": 0 }, { "fgId": 197, "fgIndex": 2, "fgType": 1 }] }
"""
val map = JSON.parseObject(fidsjson).asScala.toMap[String,Any]
val map2 = JSON.parseObject(fidsjson).getJSONArray("result").asScala.toList.map(x => x.asInstanceOf[JSONObject].asScala.toMap[String,Any])
the map is:
Map(msg -> success, result -> [{"fgId":205,"fgIndex":1,"fgType":0},{"fgId":197,"fgIndex":2,"fgType":1}], code -> 00)
the map2 is :
List(Map(fgId -> 205, fgIndex -> 1, fgType -> 0), Map(fgId -> 197, fgIndex -> 2, fgType -> 1))
core class
scala.collection.JavaConverters.asScala
网友评论