@Override
 public void settingFromJSON(JSONObject json) {
   int k;
   try {
     k = json.getInt(K_BEACONS_KEY);
     doNormalize = json.getBoolean(DO_NORMALIZE_KEY);
     kBeacons = k;
     System.out.println(this.toString());
   } catch (JSONException e) {
     e.printStackTrace();
   }
 }
 Map<Integer, String> parseIndexes(JSONObject header, String indexesName) throws JSONException {
   Map<Integer, String> map = new HashMap<Integer, String>();
   if (header.has(indexesName)) {
     JSONObject json = header.getJSONObject(indexesName);
     @SuppressWarnings("unchecked")
     Iterator<String> it = json.keys();
     while (it.hasNext()) {
       String name = it.next();
       map.put(json.getInt(name), name);
     }
   }
   return map;
 }
  public void settingFromJSON(JSONObject json) {
    jsonParams = json;
    try {
      JSONObject ldplParams = json.getJSONObject(LDPLParameters);
      JSONObject gpParams = json.getJSONObject(GPParameters);
      JSONObject optJSON = json.getJSONObject(OPTIONS);

      // LDPLParameters
      double n = ldplParams.getDouble("n");
      double A = ldplParams.getDouble("A");
      double fa = ldplParams.getDouble("fa");
      double fb = ldplParams.getDouble("fb");
      if (ldplParams.containsKey(HDIFF)) {
        double hDiff = ldplParams.getDouble(HDIFF);
        this.setParams(new double[] {n, A, fa, fb});
        this.setHDiff(hDiff);
      }

      // GPParamters
      JSONArray jarray = gpParams.getJSONArray("lengthes");
      lengthes = JSONUtils.array1DfromJSONArray(jarray);
      stdev = gpParams.getDouble("sigmaP");
      sigmaN = gpParams.getDouble("sigmaN");

      boolean useMask = (gpParams.getInt("useMask") == 1);
      int optConstVar = gpParams.getInt("constVar");

      gpLDPL.setUseMask(useMask);
      gpLDPL.setOptConstVar(optConstVar);

      // Options
      doHyperParameterOptimize = optJSON.optBoolean("optimizeHyperParameters");
      if (!doHyperParameterOptimize) {
        doHyperParameterOptimize = optJSON.optInt("optimizeHyperParameters") == 1;
      }

      // Optional variables
      if (gpParams.containsKey(ARRAYS)) {
        JSONObject jobjArrays = gpParams.getJSONObject(ARRAYS);
        gpLDPL.fromJSON(jobjArrays);
      }
      if (json.containsKey(LIKELIHOOD_MODEL)) {
        JSONObject likelihoodJSON = json.getJSONObject(LIKELIHOOD_MODEL);
        LikelihoodModel likelihoodModel = LikelihoodModelFactory.create(likelihoodJSON);
        gpLDPL.setLikelihoodModel(likelihoodModel);
      } else {
        System.out.println("The key for [" + LIKELIHOOD_MODEL + "] was not found.");
      }

      if (json.containsKey(BEACON_FILTER)) {
        JSONObject bfJSON = json.getJSONObject(BEACON_FILTER);
        BeaconFilter bf = BeaconFilterFactory.create(bfJSON);
        beaconFilter = bf;
      } else {
        System.out.println("The key for [" + BEACON_FILTER + "] was not found.");
      }

    } catch (JSONException e) {
      e.printStackTrace();
    }
  }