How to convert JSON Array to normal Java Array?

The get method of the JSONArray class returns the element at a particular index. Using this method, you can get the elements of the JSONArray object and populate the array with them.

Example

import java.util.Arrays;
import org.json.JSONArray;

public class JsonToArray {
   public static void main(String args[]) throws Exception {
      String [] myArray = {"JavaFX", "HBase", "JOGL", "WebGL"};
      JSONArray jsArray = new JSONArray();
      for (int i = 0; i 

Output

["JavaFX","HBase","JOGL","WebGL"]
Contents of the array :: [JavaFX, HBase, JOGL, WebGL]
Updated on: 2020-02-19T12:24:47+05:30

3K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements