Package org.apache.wink.json4j

Examples of org.apache.wink.json4j.JSONObject


   * @param userId
   * @param flightId
   * @return
   */
  public JSONObject getReasonForTravel(String userId, String flightId) {
    JSONObject res = new JSONObject();
    String r = "";
    try {
      JSONArray flts = (JSONArray) myFlights.get("myflights");

      @SuppressWarnings("rawtypes")
      Iterator iter = flts.iterator();
      boolean found = false;
      while (iter.hasNext() && !found) {
        JSONObject i = (JSONObject) iter.next();
       
        String flight = i.getString("FlightId");
        String user = i.getString("UserId");
        if (flightId.compareTo(flight) == 0 && user.compareTo(userId)==0) {
          r = i.getString("Reason");
          res.put("reason", r);
          found = true;
        }
      }

View Full Code Here


   * @param flightId The flight id.
   * @return The flight.
   */
    public JSONObject getFlight(String userId, String flightId) {
        final String method = "getFlight";
        JSONObject res = new JSONObject();
        JSONObject resObject = this.getMyFlights(userId);
        try {
            JSONArray flts = resObject.getJSONArray("myflights");
            Iterator<JSONObject> iter = flts.iterator();
            while(iter.hasNext()) {
                JSONObject flt = iter.next();
                if(flt.getString("FlightId").equalsIgnoreCase(flightId)){
                    res = flt;
                    break;
                }
            }
           
View Full Code Here

   *
   * @param codestream
   */
  public void load(InputStream codestream) {
    try {
      codes = new JSONObject(codestream);
    } catch (JSONException e) {
      e.printStackTrace();
    }
  }
View Full Code Here

      Object o = codes.get("airports");
      JSONArray ja = (JSONArray) o;
      @SuppressWarnings("rawtypes")
      Iterator iter = ja.iterator();
      while(iter.hasNext()){
        JSONObject jo = (JSONObject) iter.next();
        String cityT = jo.getString("city");
        String stateT = jo.getString("state");
       
        if(cityT.toLowerCase().compareTo(city.toLowerCase())==0 &&
            stateT.toLowerCase().compareTo(state.toLowerCase())==0){
          code = (String) jo.get("code");
        }
      }

    } catch (JSONException e) {
      e.printStackTrace();
View Full Code Here

      Object o = codes.get("airports");
      JSONArray ja = (JSONArray) o;
      @SuppressWarnings("rawtypes")
      Iterator iter = ja.iterator();
      while(iter.hasNext()){
        JSONObject jo = (JSONObject) iter.next();
        if(((String) jo.get("city")).toLowerCase().compareTo(city.toLowerCase())==0){
          code = (String) jo.get("code");
        }
      }

    } catch (JSONException e) {
      e.printStackTrace();
View Full Code Here

   *
   * @param codestream
   */
  public void load(InputStream codestream) {
    try {
      flightController = new JSONObject(codestream);
    } catch (JSONException e) {
      e.printStackTrace();
    }
  }
View Full Code Here

      @SuppressWarnings("rawtypes")
      Iterator iter = flts.iterator();
      boolean found = false;
      while (iter.hasNext() && !found) {
        JSONObject i = (JSONObject) iter.next();
        String flight = i.getString("Flight");
        if (flightId.compareTo(flight) == 0) {
          res = i.getString("State");
          found = true;
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

      @SuppressWarnings("rawtypes")
      Iterator iter = flts.iterator();
      boolean found = false;
      while (iter.hasNext() && !found) {
        JSONObject i = (JSONObject) iter.next();
        String flight = i.getString("Flight");
        if (flightId.compareTo(flight) == 0) {
          flts.remove(i);
          found = true;
        }
      }
View Full Code Here

   * @param state
   */
  public void addFlight(String flightId, String state) {
    try {
      JSONArray flts = (JSONArray) flightController.get("controller");
      JSONObject o = new JSONObject();
      o.put("Flight", flightId);
      o.put("State", state);
      flts.add(o);
     
      flightController.remove("controller");
      flightController.put("controller",flts);
     
View Full Code Here

            is.close();
            fos.flush();
            fos.close();

            is = fileOut.toURI().toURL().openStream();// this.getClass().getClassLoader().getResourceAsStream("json_output/utf8-lowerchar.json");
            JSONObject jObject = new JSONObject(is);
            is.close();
            String str = (String)jObject.get("hi");
            String expected="\u00C5\u00C5\u00C5\u00C5";
            //Compare this to the string with unicode \u00C5 in it.
            assertTrue(expected.equals(str));

        } catch (Exception ex1) {
View Full Code Here

TOP

Related Classes of org.apache.wink.json4j.JSONObject

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.