Java Json Convert toIntArray(JsonArray jsonArray)

Here you can find the source of toIntArray(JsonArray jsonArray)

Description

to Int Array

License

Open Source License

Declaration

public static int[] toIntArray(JsonArray jsonArray) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.json.JsonArray;
import javax.json.JsonNumber;

public class Main {
    public static int[] toIntArray(JsonArray jsonArray) {
        if (jsonArray == null)
            return new int[0];
        int[] ret = new int[jsonArray.size()];
        for (int i = 0; i < jsonArray.size(); i++) {
            ret[i] = ((JsonNumber) jsonArray.get(i)).intValue();
        }//w  w w .j a va2  s  . c  o m
        return ret;
    }
}

Related

  1. jsonArrayToBooleanList(final JsonArray arr)
  2. jsonArrayToString(final JsonArray array)
  3. toJsonString(JsonObject json)
  4. toList(JsonArray array)
  5. toString(JsonValue json)
  6. toStringArray(JsonArray jsa)