title: How to decode a base64-encoded String on a JSON File
body: <p>I have been having a hard time getting some value from my encoded JSONObject in order to decode it.</p>
  
  <p>server.json data file:</p>
  
  <pre><code>{
    "servers": [
      {
        "name": "Server 1",
        "domain": "157.230.228.67",
        "port": 465,
        "location": "ph",
        "http_server": "157.230.228.67",
        "http_port": 8000
      },
      {
        "name": "Server 2",
        "domain": "157.230.228.67",
        "port": 465,
        "location": "ph",
        "http_server": "10.199.212.2",
        "http_port": 8080
      }
    ],
    "payloads": [
      {
        "name": "Payload 1",
        "host": "IWdvb2dsZS5jb20="
      },
      {
        "name": "Payload 2",
        "host": "IWdvb2dsZS5jb20="
      },
      {
        "name": "Payload 3",
        "host": "IWdvb2dsZS5jb20="
      }
    ]
  }
  </code></pre>
  
  <p>Now I only want to call and decode the (host)value maybe using jsonObject or JSONArray;
  A code snippet of my Mainactivity Class;
   This load the server.json on the main activity.</p>
  
  <pre><code>server_file = FileUtility.readFileFromAssets(getAssets(), "servers.json"); // LOAD
          Log.e("List", "onCreate: " + server_file);
  
  
  
  
  
  
      JSONObject jsonObject = null;
              try {
                  jsonObject = new JSONObject(server_file);
              } catch (JSONException e) {
                  e.printStackTrace();
              }
              JSONArray key = jsonObject.names();
              for (int i = 0; i &lt;key.length() ; i++) {
                  try {
                      String keys = key.getString(i);
                      String value = jsonObject.getString(keys);
                      byte[] decode = Base64.getDecoder().decode(value);
                      String showDecode = new String(decode, "UTF-8");
                  } catch (JSONException e) {
                      e.printStackTrace();
                  } catch (UnsupportedEncodingException e) {
                      e.printStackTrace();
                  }
                  try {
                      Log.d(TAG, "key: " + jsonObject.names().getString(i) + "value: " + jsonObject.get(jsonObject.names().getString(i)));
                  } catch (JSONException e) {
                      e.printStackTrace();
                  }
  </code></pre>
  
  <p>Now my main issue is how to call for the specific value which is (host) value in order to base64-decode it before it gets launched on my main activity.</p>
  
  <p>+The value of the host before encoding is a String data type.</p>