All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nitorcreations.willow.auth.JSONTool Maven / Gradle / Ivy

The newest version!
package com.nitorcreations.willow.auth;

import static java.util.Collections.unmodifiableSet;

import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

import org.json.JSONArray;
import org.json.JSONException;

enum JSONTool {
  ;

  static Set toStringSet(JSONArray array) throws JSONException {
    Set set = new LinkedHashSet<>();
    for(int i = 0; i < array.length(); i++) {
      set.add(array.getString(i));
    }
    return unmodifiableSet(set);
  }

  static JSONArray toArray(List list1, List list2) { // generics and varargs don't match..
    JSONArray array = new JSONArray();
    for(String s : list1) {
      array = array.put(s);
    }
    for(String s : list2) {
      array = array.put(s);
    }
    return array;
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy