Java-JSONArray jsonArray = JSONArray.fromObject()使用


背景:获取结果为["1","2","3"]的类型为object,想要获取里边的数据值,只能转换为JSONArray,下边记录一下我转换的过程!

1.添加依赖的jar包

        
            commons-beanutils
            commons-beanutils
            1.9.3
        
        
            commons-collections
            commons-collections
            3.2.1
        
        
            commons-lang
            commons-lang
            2.6
        
        
            commons-logging
            commons-logging
            1.1.1
        
        
            net.sf.ezmorph
            ezmorph
            1.0.6
        
        
        
            net.sf.json-lib
            json-lib
            2.2.3
            jdk15
        

2.类引用

import net.sf.json.JSONArray;

JSONArray jsonArray = JSONArray.fromObject(object);