Commit f6c328a9 authored by shiyl's avatar shiyl

优化JsonUtil

parent 68efc370
......@@ -40,13 +40,13 @@ object JsonUtils {
* @param json
* @return
*/
fun parseJSON2Map(json: JSONObject): Map<String, Any> {
fun parseJSON2Map(json: JSONObject): Map<String, Any?> {
val map: MutableMap<String, Any> = HashMap()
// 最外层解析
for (k in json.keys()) {
when (val v = json[k]) {
is JSONArray -> {// 如果内层还是json数组的话,继续解析
val list: MutableList<Map<String, Any>> = ArrayList()
val list: MutableList<Map<String, Any?>> = ArrayList()
for (i in 0 until v.length()) {
val jsonObject = v.getJSONObject(i)
list.add(parseJSON2Map(jsonObject))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment