code: public static JSONObject toJSONObject(String string) throws JSONException {
      String n;
      JSONObject o = new JSONObject();
      Object v;
      JSONTokener x = new JSONTokener(string);
      o.put("name", x.nextTo('='));
      x.next('=');
      o.put("value", x.nextTo(';'));
      x.next();
      while (x.more()) {
        n = unescape(x.nextTo("=;"));
        if (x.next() != '=') {
          if (n.equals("secure")) {
            v = Boolean.TRUE;
          } else {
            throw x.syntaxError("Missing '=' in cookie parameter.");
          }
        } else {
          v = unescape(x.nextTo(';'));
          x.next();
        }
        o.put(n, v);
      }
      return o;
    }
docs: Convert a cookie specification string into a JSONObject. The string will contain a name value pair separated by '='. The name and the value will be unescaped, possibly converting '+' and '%'
  sequences. The cookie properties may follow, separated by ';', also represented as name=value (except the secure property, which does not have a value). The name will be stored under the key
  "name", and the value will be stored under the key "value". This method does not do checking or validation of the parameters. It only converts the cookie string into a JSONObject.
  
  @param string
  The cookie specification string.
  @return A JSONObject containing "name", "value", and possibly other members.
  @throws JSONException