import net.minidev.json.parser.JSONParser import net.minidev.json.JSONObject
import scala.collection.mutable import
scala.collection.JavaConversions.mapAsScalaMap import
scala.collection.JavaConversions.mutableMapAsJavaMapdef jsonToMap(svdInfo:
String) = { val parserJson = new JSONParser() val jsonObj: JSONObject =
parserJson.parse(svdInfo).asInstanceOf[JSONObject] /* val tagName =
jsonObj.get("tagName").toString println("tagName===:" + tagName)*/ val jsonKey
= jsonObj.keySet() val iter = jsonKey.iterator() val map:
mutable.HashMap[String, String] = new mutable.HashMap[String, String]() while
(iter.hasNext) { val instance = iter.next() val value =
jsonObj.get(instance).toString // map += (instance -> value) map.put(instance,
value) println("===key====:" + instance + "===value===:" + value) } map } def
jsonToMap1(svdInfo: String) = { val parserJson = new JSONParser() val jsonObj:
JSONObject = parserJson.parse(svdInfo).asInstanceOf[JSONObject] /* val tagName
= jsonObj.get("tagName").toString println("tagName===:" + tagName)*/ val
jsonKey = jsonObj.keySet() val iter = jsonKey.iterator() val map:
mutable.HashMap[String, Object] = new mutable.HashMap[String, Object]() while
(iter.hasNext) { val instance = iter.next() val value =
jsonObj.get(instance).toString if (value.startsWith("{") &&
value.endsWith("}")) { val value =
mapAsScalaMap(jsonObj.get(instance).asInstanceOf[mutable.HashMap[String,
String]]) map.put(instance, value) } else map += (instance -> value) //
println("===key====:" + instance + "===value===:" + value) } map }
//获取Option里的数据 def show(x: Option[Object]): Object = x match { case Some(s) =>
s case None => "" }






友情链接
KaDraw流程图
API参考文档
OK工具箱
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:637538335
关注微信