Package net.minidev.json

Examples of net.minidev.json.JSONArray


   */
  public JSONObject toJSONObject(final boolean publicKeysOnly) {

    JSONObject o = new JSONObject(customMembers);

    JSONArray a = new JSONArray();

    for (JWK key: keys) {

      if (publicKeysOnly) {

        // Try to get public key, then serialise
        JWK publicKey = key.toPublicJWK();

        if (publicKey != null) {
          a.add(publicKey.toJSONObject());
        }
      } else {

        a.add(key.toJSONObject());
      }
    }

    o.put("keys", a);

View Full Code Here


   *                        JSON Web Key (JWK) set.
   */
  public static JWKSet parse(final JSONObject json)
    throws ParseException {

    JSONArray keyArray = JSONObjectUtils.getJSONArray(json, "keys");

    List<JWK> keys = new LinkedList<JWK>();

    for (int i=0; i < keyArray.size(); i++) {

      if (! (keyArray.get(i) instanceof JSONObject)) {
        throw new ParseException("The \"keys\" JSON array must contain JSON objects only", 0);
      }

      JSONObject keyJSON = (JSONObject)keyArray.get(i);

      try {
        keys.add(JWK.parse(keyJSON));

      } catch (ParseException e) {
View Full Code Here

    if (sub != null) {
      o.put(SUBJECT_CLAIM, sub);
    }

    if (aud != null) {
      JSONArray audArray = new JSONArray();
      audArray.addAll(aud);
      o.put(AUDIENCE_CLAIM, audArray);
    }

    if (exp != null) {
      o.put(EXPIRATION_TIME_CLAIM, exp.getTime() / 1000);
View Full Code Here

    if (qi != null) {
      o.put("qi", qi.toString());
    }
    if (oth != null && !oth.isEmpty()) {

      JSONArray a = new JSONArray();

      for (OtherPrimesInfo other : oth) {

        JSONObject oo = new JSONObject();
        oo.put("r", other.r.toString());
        oo.put("d", other.d.toString());
        oo.put("t", other.t.toString());

        a.add(oo);
      }

      o.put("oth", a);
    }
View Full Code Here

    }
   
    List<OtherPrimesInfo> oth = null;
    if (jsonObject.containsKey("oth")) {

      JSONArray arr = JSONObjectUtils.getJSONArray(jsonObject, "oth");
      oth = new ArrayList<RSAKey.OtherPrimesInfo>(arr.size());
     
      for (Object o : arr) {

        if (o instanceof JSONObject) {
          JSONObject otherJson = (JSONObject)o;
View Full Code Here

   *                        of the expected type.
   */
  public static String[] getStringArray(final JSONObject o, final String key)
      throws ParseException {

    JSONArray jsonArray = getJSONArray(o, key);

    try {
      return jsonArray.toArray(new String[0]);

    } catch (ArrayStoreException e) {

      throw new ParseException("JSON object member with key \"" + key + "\" is not an array of strings", 0);
    }
View Full Code Here

TOP

Related Classes of net.minidev.json.JSONArray

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.