/**
   * Creates a new, empty ServiceRequest
   *
   * <p>This does not load any user-submitted data and should only be used for initial startup.
   * Subsequent loads should be done using the JSON String version
   *
   * @param s A single service from GET Service List
   */
  public ServiceRequest(JSONObject s, Context c) {
    service = s;
    post_data = new JSONObject();

    if (service.optBoolean(Open311.METADATA)) {
      try {
        service_definition =
            Open311.getServiceDefinition(service.getString(Open311.SERVICE_CODE), c);
      } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }

    // Read in the personal info fields from Preferences
    JSONObject personalInfo = Preferences.getPersonalInfo(c);
    Iterator<?> keys = personalInfo.keys();
    while (keys.hasNext()) {
      try {
        String key = (String) keys.next();
        String value = personalInfo.getString(key);
        if (value != "") {
          post_data.put(key, value);
        }
      } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
  }
 /**
  * Returns the name from a single value in an attribute
  *
  * @param code The attribute code
  * @param key The value key
  * @return String
  */
 public String getAttributeValueName(String code, String key) {
   JSONArray values = getAttributeValues(code);
   int len = values.length();
   try {
     for (int i = 0; i < len; i++) {
       JSONObject v = values.getJSONObject(i);
       String k = v.getString(Open311.KEY);
       if (k.equals(key)) {
         return v.getString(Open311.NAME);
       }
     }
   } catch (JSONException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   return null;
 }
 /**
  * Returns the URL for getting a service_request_id from a token
  *
  * @param token
  * @return String
  * @throws JSONException
  */
 public String getServiceRequestIdFromTokenUrl(String token) throws JSONException {
   String baseUrl = endpoint.getString(Open311.URL);
   String jurisdiction = endpoint.optString(Open311.JURISDICTION);
   return String.format(
       "%s/tokens/%s.json?%s=%s", baseUrl, token, Open311.JURISDICTION, jurisdiction);
 }
 /**
  * Returns the URL for getting fresh information from the endpoint
  *
  * @param request_id
  * @return String
  * @throws JSONException
  */
 public String getServiceRequestUrl(String request_id) throws JSONException {
   String baseUrl = endpoint.getString(Open311.URL);
   String jurisdiction = endpoint.optString(Open311.JURISDICTION);
   return String.format(
       "%s/requests/%s.json?%s=%s", baseUrl, request_id, Open311.JURISDICTION, jurisdiction);
 }