语法
public Object[] toArray()
import java.util.Arrays; import net.sf.json.JSONArray; public class ConvertJSONArrayToArrayTest { public static void main(String[] args) { JSONArray jsonArray = new JSONArray() .element("Raja Ramesh") .element("115") .element("Tutorials Point") .element("Hyderabad") .element(new String [] {"Java", "Testing", "Python"}); String jsonStr = jsonArray.toString(3); //pretty print JSON System.out.println("JSON:\n" + jsonStr); Object[] array = jsonArray.toArray(); System.out.println("-------------------------------------------------------------------"); System.out.println("Array:\n" + Arrays.toString(array)); } }
JSON: [ "Raja Ramesh", "115", "Tutorials Point", "Hyderabad", [ "Java", "Testing", "Python" ] ] ---------------------------------------------------------------------------- Array: [Raja Ramesh, 115, Tutorials Point, Hyderabad, ["Java","Testing","Python"]]
以上就是如何使用Java中的JSON-lib API将JSON数组转换为数组?的详细内容,更多请关注php中文网其它相关文章!
已抢23463个
抢已抢117922个
抢已抢139319个
抢已抢6240个
抢已抢35866个
抢已抢66646个
抢