Examples of JSONObject


Examples of org.apache.tomcat.util.json.JSONObject

                    if (rq!=null) {
                        Map map = new HashMap();
                        try {
                            map.put(Bayeux.CHANNEL_FIELD,message.getChannel().getId());
                            map.put(Bayeux.DATA_FIELD,message);
                            JSONObject json = new JSONObject(map);
                            if (log.isTraceEnabled()) {
                                log.trace("Message instantly delivered to remote client["+this+"] message:"+json);
                            }
                            rq.addToDeliveryQueue(this, json);
                            //deliver the batch
View Full Code Here

Examples of org.apache.wicket.ajax.json.JSONObject

   * @return the attributes as string in JSON format
   */
  protected final CharSequence renderAjaxAttributes(final Component component,
    AjaxRequestAttributes attributes)
  {
    JSONObject attributesJson = new JSONObject();

    try
    {
      attributesJson.put("u", getCallbackUrl());
      Method method = attributes.getMethod();
      if (Method.POST == method)
      {
        attributesJson.put("m", method);
      }

      if (component instanceof Page == false)
      {
        String componentId = component.getMarkupId();
        attributesJson.put("c", componentId);
      }

      String formId = attributes.getFormId();
      if (Strings.isEmpty(formId) == false)
      {
        attributesJson.put("f", formId);
      }

      if (attributes.isMultipart())
      {
        attributesJson.put("mp", true);
      }

      String submittingComponentId = attributes.getSubmittingComponentName();
      if (Strings.isEmpty(submittingComponentId) == false)
      {
        attributesJson.put("sc", submittingComponentId);
      }

      String indicatorId = findIndicatorId();
      if (Strings.isEmpty(indicatorId) == false)
      {
        attributesJson.put("i", indicatorId);
      }

      for (IAjaxCallListener ajaxCallListener : attributes.getAjaxCallListeners())
      {
        if (ajaxCallListener != null)
        {
          CharSequence beforeHandler = ajaxCallListener.getBeforeHandler(component);
          appendListenerHandler(beforeHandler, attributesJson, "bh",
            BEFORE_HANDLER_FUNCTION_TEMPLATE);

          CharSequence beforeSendHandler = ajaxCallListener.getBeforeSendHandler(component);
          appendListenerHandler(beforeSendHandler, attributesJson, "bsh",
            BEFORE_SEND_HANDLER_FUNCTION_TEMPLATE);

          CharSequence afterHandler = ajaxCallListener.getAfterHandler(component);
          appendListenerHandler(afterHandler, attributesJson, "ah",
            AFTER_HANDLER_FUNCTION_TEMPLATE);

          CharSequence successHandler = ajaxCallListener.getSuccessHandler(component);
          appendListenerHandler(successHandler, attributesJson, "sh",
            SUCCESS_HANDLER_FUNCTION_TEMPLATE);

          CharSequence failureHandler = ajaxCallListener.getFailureHandler(component);
          appendListenerHandler(failureHandler, attributesJson, "fh",
            FAILURE_HANDLER_FUNCTION_TEMPLATE);

          CharSequence completeHandler = ajaxCallListener.getCompleteHandler(component);
          appendListenerHandler(completeHandler, attributesJson, "coh",
            COMPLETE_HANDLER_FUNCTION_TEMPLATE);

          CharSequence precondition = ajaxCallListener.getPrecondition(component);
          appendListenerHandler(precondition, attributesJson, "pre",
            PRECONDITION_FUNCTION_TEMPLATE);
        }
      }

      JSONArray extraParameters = JsonUtils.asArray(attributes.getExtraParameters());

      if (extraParameters.length() > 0)
      {
        attributesJson.put("ep", extraParameters);
      }

      List<CharSequence> dynamicExtraParameters = attributes.getDynamicExtraParameters();
      if (dynamicExtraParameters != null)
      {
        for (CharSequence dynamicExtraParameter : dynamicExtraParameters)
        {
          String func = String.format(DYNAMIC_PARAMETER_FUNCTION_TEMPLATE,
            dynamicExtraParameter);
          JsonFunction function = new JsonFunction(func);
          attributesJson.append("dep", function);
        }
      }

      if (attributes.isAsynchronous() == false)
      {
        attributesJson.put("async", false);
      }

      String[] eventNames = attributes.getEventNames();
      if (eventNames.length == 1)
      {
        attributesJson.put("e", eventNames[0]);
      }
      else
      {
        for (String eventName : eventNames)
        {
          attributesJson.append("e", eventName);
        }
      }

      AjaxChannel channel = attributes.getChannel();
      if (channel != null)
      {
        attributesJson.put("ch", channel);
      }

      if (attributes.isAllowDefault())
      {
        attributesJson.put("ad", true);
      }

      Duration requestTimeout = attributes.getRequestTimeout();
      if (requestTimeout != null)
      {
        attributesJson.put("rt", requestTimeout.getMilliseconds());
      }

      boolean wicketAjaxResponse = attributes.isWicketAjaxResponse();
      if (wicketAjaxResponse == false)
      {
        attributesJson.put("wr", false);
      }

      String dataType = attributes.getDataType();
      if (AjaxRequestAttributes.XML_DATA_TYPE.equals(dataType) == false)
      {
        attributesJson.put("dt", dataType);
      }

      ThrottlingSettings throttlingSettings = attributes.getThrottlingSettings();
      if (throttlingSettings != null)
      {
        JSONObject throttlingSettingsJson = new JSONObject();
        throttlingSettingsJson.put("id", throttlingSettings.getId());
        throttlingSettingsJson.put("d", throttlingSettings.getDelay().getMilliseconds());
        if (throttlingSettings.getPostponeTimerOnUpdate())
        {
          throttlingSettingsJson.put("p", true);
        }
        attributesJson.put("tr", throttlingSettingsJson);
      }

      postprocessConfiguration(attributesJson, component);
View Full Code Here

Examples of org.apache.wink.json4j.JSONObject

        if(!"lists".equalsIgnoreCase(paths[0]) && paths.length > 0 && paths[1].equalsIgnoreCase("lists")){
            //Must be flights for a specific user
            String userId = paths[0];
            String postBody = getBody(req);
            try {
                JSONObject flight = new JSONObject(postBody);
                if(!flight.has(FLIGHT_ID) || !flight.has(APPROVER_ID)) {
                    resp.sendError(HttpServletResponse.SC_BAD_REQUEST,
                            "The POST body must have the following properties: FlightId, UserId, ApproverId");
                    return;
                }
                String flightId = flight.getString(FLIGHT_ID);
                if(flightAlreadyBooked(flightId, userId)) {
                    resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
                    resp.flushBuffer();
                    return;
                }
                MyFlights.getInstance().addMyFlight(flight.getString(FLIGHT_ID), userId,
                        flight.getString(APPROVER_ID), flight.optString(REASON));
                resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
                resp.flushBuffer();
                return;
            } catch (JSONException e) {
                resp.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage());
View Full Code Here

Examples of org.apache.wink.json4j.compat.JSONObject

        try {
            System.setProperty("org.apache.wink.common.model.json.factory.impl", "org.apache.wink.json4j.compat.impl.ApacheJSONFactory");
            JSONFactory factory = JSONFactory.newInstance();
            JSONArray jArray = factory.createJSONArray();
            jArray.put(factory.createJSONObject());
            JSONObject obj = (JSONObject)jArray.get(0);
            assertTrue(obj != null);
            assertTrue(obj instanceof JSONObject);
            assertTrue(((JSONObject)jArray.get(0)).toString().equals("{}"));
        } catch (Exception ex1) {
            ex = ex1;
View Full Code Here

Examples of org.auto.json.JsonObject

* @author XiaohangHu
*/
public class JsonProtocolUtils {

  public static String getCloseCommend() {
    JsonObject commend = new JsonObject();
    commend.put(Protocol.SYNCHRONIZE_KEY, Protocol.DISCONNECT_VALUE);
    return commend.toString();
  }
View Full Code Here

Examples of org.camunda.bpm.engine.impl.util.json.JSONObject

  @Test
  @SuppressWarnings("unchecked")
  public void testJsonObjectToMap() {
    assertNull(jsonObjectAsMap(null));

    JSONObject jsonObject = new JSONObject();

    Map<String, Object> map = jsonObjectAsMap(jsonObject);
    assertTrue(map.isEmpty());

    jsonObject.put("boolean", true);
    jsonObject.put("int", 12);
    jsonObject.put("double", 11.1);
    jsonObject.put("long", 13l);
    jsonObject.put("string", "test");
    jsonObject.put("list", Collections.singletonList("test"));
    jsonObject.put("map", Collections.singletonMap("test", "test"));
    jsonObject.put("date", new Date(0));

    map = jsonObjectAsMap(jsonObject);
    assertEquals(8, map.size());

    assertEquals(true, map.get("boolean"));
View Full Code Here

Examples of org.codehaus.groovy.grails.web.json.JSONObject

{
  public static Map<String, Object> doPost(String url, Map<String, Object> bodyMap, Integer connectionTimeout, Integer soTimeout)
  {
    Map<String, Object> resp = postJSON(url, MapUtil.mapToString(bodyMap), connectionTimeout, soTimeout);
    if (!resp.containsKey("exception"))
      resp.put("response", MapUtil.jsonObjectToMap(new JSONObject((String) resp.get("response"))));
    return resp;
  }
View Full Code Here

Examples of org.codehaus.jettison.json.JSONObject

                                        feed.destroy();
                                        logger.info("Twitter Search API unavaileble\n{}", s);
                                        return null;
                                    }

                                    JSONObject json = new JSONObject(s);
                                    refreshUrl.set(json.getString("refresh_url"));
                                    if (json.getJSONArray("results").length() > 1) {
                                        feed.broadcast(s).get();
                                    }
                                    return null;
                                }
View Full Code Here

Examples of org.eclipse.rap.json.JsonObject

    assertNull( appEvent.getProperty( "foo" ) );
  }

  @Test
  public void testReturnsCorrectProperty() {
    JsonObject properties = new JsonObject();
    properties.add( "foo", "bar" );

    AppEvent appEvent = new AppEvent( EventType.PAUSE, properties );

    assertEquals( JsonValue.valueOf( "bar" ), appEvent.getProperty( "foo" ) );
  }
View Full Code Here

Examples of org.eclipse.rap.rwt.internal.theme.JsonObject

  }

  @Override
  protected void doGet( HttpServletRequest req, HttpServletResponse resp ) throws ServletException, IOException {
    Collection<String> servletPaths = manager.getServletPaths();
    JsonObject jsonObject = createMessageObject( servletPaths );
    resp.setContentType( "application/json" );
    resp.getWriter().write( jsonObject.toString() );
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.