Examples of JSONObject


Examples of org.hornetq.utils.json.JSONObject

   {
      Map<SimpleString, Pair<UUID, AtomicLong>> targetCopy = cloneTargetAddresses();
     
      for (Map.Entry<SimpleString, Pair<UUID, AtomicLong>> entry : targetCopy.entrySet())
      {
         JSONObject producerInfo = new JSONObject();
         producerInfo.put("connectionID", this.getConnectionID().toString());
         producerInfo.put("sessionID", this.getName());
         producerInfo.put("destination", entry.getKey().toString());
         producerInfo.put("lastUUIDSent", entry.getValue().a);
         producerInfo.put("msgSent", entry.getValue().b.longValue());
         array.put(producerInfo);
      }
   }
View Full Code Here

Examples of org.infinispan.server.websocket.json.JsonObject

    * @param ctx   The channel context associated with the browser websocket channel..
    */
   public static void pushCacheValue(String key, Cache<Object, Object> cache, ChannelHandlerContext ctx) {
      Object value = cache.get(key);

      JsonObject responseObject = toJSON(key, value, cache.getName());

      // Write the JSON response out onto the channel...
      ctx.channel().writeAndFlush(new TextWebSocketFrame(responseObject.toString()));
   }
View Full Code Here

Examples of org.jose4j.json.internal.json_simple.JSONObject

      token = new Yytoken(Yytoken.TYPE_EOF, null);
  }
 
  private Map createObjectContainer(ContainerFactory containerFactory){
    if(containerFactory == null)
      return new JSONObject();
    Map m = containerFactory.createObjectContainer();
   
    if(m == null)
      return new JSONObject();
    return m;
  }
View Full Code Here

Examples of org.json.JSONObject

      }

      String metadata_ = GadgetUtil.fetchGagdetMetadata(url);
      try
      {
         JSONObject jsonObj = new JSONObject(metadata_);
         JSONObject obj = jsonObj.getJSONArray("gadgets").getJSONObject(0);
         String token = GadgetUtil.createToken(url, new Long(hashCode()));
         obj.put("secureToken", token);
         metadata_ = jsonObj.toString();
      }
      catch (JSONException e)
      {
         e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
View Full Code Here

Examples of org.json.jdk5.simple.JSONObject

  public static String getThesauri() {
    JSONArray ja = new JSONArray();
   
    for(ThesaurusContext context:Thesauri.getInstance().getContexts())
    {
      JSONObject jo = new JSONObject();
      jo.put("label", context.getLabel());
      jo.put("uri", context.getUri().toString());
     
      ja.add(jo);
    }
   
    return ja.toString();
View Full Code Here

Examples of org.json.me.JSONObject

            throws JSONException, IOException {
        log("parseMessage(NDEFMessage)");
        String record_type = "?";
        int typeNameFormat = NDEFRecord.TNF_WELL_KNOWN;

        JSONObject result = new JSONObject();
        /*
         * The NDEF Message may consist of a number of NDEF records
         */

        NDEFRecord[] records = _message.getRecords();
        /*
         * This is the number of NDEF records in the NDEF message
         */
        int numRecords = records.length;

        log("Parsing #records=" + numRecords);

        /*
         * Only unpick the message if it contains a non-zero number of records
         */
        JSONArray recordsArray = new JSONArray();
        result.put(Constants.NDEF_RECORDS, recordsArray);

        if (numRecords > 0) {
            /*
             * Work our way through each record in the message in turn
             */
            for (int j = 0; j < numRecords; ++j) {
                log("parseMessage record #" + j);

                NDEFRecord currentRecord = records[j];
                JSONObject jsonRecord = new JSONObject();
                recordsArray.put(jsonRecord);

                log("Processing NDEF record#=" + j);

                typeNameFormat = currentRecord.getTypeNameFormat();
                record_type = records[j].getType();

                if (typeNameFormat == NDEFRecord.TNF_WELL_KNOWN) {
                    if (Constants.NDEF_SMART_POSTER_TYPE.equals(records[j]
                            .getType())) {
                        mergeInto(jsonRecord, parseSmartPoster(records[j]));
                    } else if (Constants.NDEF_TEXT_TYPE.equals(records[j]
                            .getType())) {
                        mergeInto(jsonRecord, parseText(records[j]));
                    } else if (Constants.NDEF_URI_TYPE.equals(records[j]
                            .getType())) {
                        mergeInto(jsonRecord, parseURI(records[j]));
                    } else {
                        // Gc, Hr, Hs, Hc, Sig are not currently parsed by this
                        // implementation...
                    }
                } else if (typeNameFormat == NDEFRecord.TNF_MEDIA) {
                    mergeInto(jsonRecord, parseMediaRecord(records[j]));
                } else if (typeNameFormat == NDEFRecord.TNF_EXTERNAL) {
                    NDEFMessage message = new NDEFMessage(
                            records[j].getPayload());
                    mergeInto(jsonRecord, parseMessage(message));
                }

                if (!jsonRecord.has(Constants.NDEF_PAYLOAD64)) {
                    mergeInto(jsonRecord, parseGenericRecord(records[j]));
                }

                // Put the first record at the top level - to simplify
                // accessing.
View Full Code Here

Examples of org.json.simple.JSONObject

      Map result = new HashMap();

      if ( tid != null )result.put( "tid", tid );

      try{
        JSONObject  payload = new JSONObject();
       
          // change this you need to change update too below
       
        payload.put( "engine_id", decodedMap.get( "engine_id" ));
        payload.put( "search_term", decodedMap.get( "search_term" ));
        payload.put( "filters", decodedMap.get( "filters" ));
        payload.put( "schedule", decodedMap.get( "schedule" ));
        payload.put( "options", decodedMap.get( "options" ));
       
        Subscription subs = SubscriptionManagerFactory.getSingleton().create(name, isPublic.booleanValue(), payload.toString());
       
        subs.getHistory().setDetails(
          isEnabled==null?true:isEnabled.booleanValue(),
          autoDownload==null?false:autoDownload.booleanValue());
               
        result.put( "id", subs.getID());
       
        sendBrowserMessage( "metasearch", "createSubscriptionCompleted", result );

      } catch( Throwable e ){
       
        result.put( "error", "create failed: " + Debug.getNestedExceptionMessage(e));

        sendBrowserMessage( "metasearch", "createSubscriptionFailed", result );
      }
    }else if( OP_READ_SUBSCRIPTION.equals(opid)){
     
      Map decodedMap = message.getDecodedMap();
     
      final Long   tid = (Long) decodedMap.get("tid");

      final String sid = (String) decodedMap.get("id");
     
      Map result = new HashMap();

      if ( tid != null )result.put( "tid", tid );

      try{
        Subscription subs = SubscriptionManagerFactory.getSingleton().getSubscriptionByID( sid );
       
        if ( subs == null ){
         
          result.put( "error", "Subscription not found" );

          sendBrowserMessage("metasearch", "readSubscriptionFailed",result);
         
        }else{
               
          boolean  shareable = subs.isShareable();
         
            // override public flag if not shareable
         
          result.put( "id", subs.getID());
          result.put( "name", subs.getName());
          result.put( "is_public", new Boolean( shareable && subs.isPublic()));
          result.put( "is_author", new Boolean( subs.isMine()));
          result.put( "is_shareable", new Boolean( shareable ));
          result.put( "auto_dl_supported", new Boolean( subs.isAutoDownloadSupported()));
         
          SubscriptionHistory history = subs.getHistory();
         
          Map  options = new HashMap();

          result.put( "options", options );

          options.put( "is_enabled", new Boolean( history.isEnabled()));
          options.put( "auto_dl", new Boolean( history.isAutoDownload()));
         
          Map  info = new HashMap();

          result.put( "info", info );
         
          info.put( "last_scan", new Long( history.getLastScanTime()));
          info.put( "last_new", new Long( history.getLastNewResultTime()));
          info.put( "num_unread", new Long( history.getNumUnread()));
          info.put( "num_read", new Long( history.getNumRead()));
         
          String json = subs.getJSON();
         
          Map map = JSONUtils.decodeJSON( json );
         
          result.put( "engine_id", map.get( "engine_id" ));
          result.put( "search_term", map.get( "search_term" ));
          result.put( "filters", map.get( "filters" ));
          result.put( "schedule", map.get( "schedule" ));
         
          sendBrowserMessage( "metasearch", "readSubscriptionCompleted", result );
        }
      } catch( Throwable e ){
       
        result.put( "error", "read failed: " + Debug.getNestedExceptionMessage(e));

        sendBrowserMessage("metasearch", "readSubscriptionFailed",result);
      }
    }else if (OP_UPDATE_SUBSCRIPTION.equals(opid)) {
     
      Map decodedMap = message.getDecodedMap();
     
      final Long   tid = (Long) decodedMap.get("tid");
     
      final String   name     = (String)decodedMap.get("name");
      final Boolean   isPublic  = (Boolean)decodedMap.get( "is_public" );
      final String   sid     = (String)decodedMap.get("id");
     
      Map      options    = (Map)decodedMap.get( "options" );
     
      Boolean   isEnabled    = (Boolean)options.get( "is_enabled" );
      Boolean   autoDownload  = (Boolean)options.get( "auto_dl" );

      Map result = new HashMap();

      if ( tid != null )result.put( "tid", tid );

      try{
        Subscription subs = SubscriptionManagerFactory.getSingleton().getSubscriptionByID( sid );
       
        if ( subs == null ){
         
          result.put( "error", "Subscription not found" );

          sendBrowserMessage("metasearch", "updateSubscriptionFailed",result);
         
        }else{
         
          JSONObject  payload = new JSONObject();
         
            // change this you need to change create too above
       
          payload.put( "engine_id", decodedMap.get( "engine_id" ));
          payload.put( "search_term", decodedMap.get( "search_term" ));
          payload.put( "filters", decodedMap.get( "filters" ));
          payload.put( "schedule", decodedMap.get( "schedule" ));
          payload.put( "options", decodedMap.get( "options" ));
       
          boolean  changed = subs.setDetails( name, isPublic.booleanValue(), payload.toString());
         
          subs.getHistory().setDetails(
              isEnabled==null?true:isEnabled.booleanValue(),
              autoDownload==null?false:autoDownload.booleanValue());
View Full Code Here

Examples of org.json_voltpatches.JSONObject

        while (vt.advanceRow()) {
            try {
                //Data embedded in JSON object in remarks column
                String jsString = vt.getString(6);
                String procedureName = vt.getString(2);
                JSONObject jsObj = new JSONObject(jsString);
                boolean readOnly = jsObj.getBoolean(Constants.JSON_READ_ONLY);
                if (jsObj.getBoolean(Constants.JSON_SINGLE_PARTITION)) {
                    int partitionParameter = jsObj.getInt(Constants.JSON_PARTITION_PARAMETER);
                    int partitionParameterType =
                        jsObj.getInt(Constants.JSON_PARTITION_PARAMETER_TYPE);
                    m_procedureInfo.put(procedureName,
                            new Procedure(false,readOnly, partitionParameter, partitionParameterType));
                } else {
                    // Multi Part procedure JSON descriptors omit the partitionParameter
                    m_procedureInfo.put(procedureName, new Procedure(true, readOnly, Procedure.PARAMETER_NONE,
View Full Code Here

Examples of org.jtester.json.helper.JSONObject

   */
  public static final <T> T toObject(String json) {
    if (json == null) {
      return null;
    }
    JSONObject jsonObject = JSONScanner.scnJSON(json);

    Object o = toObject(jsonObject, new HashMap<String, Object>());
    return (T) o;
  }
View Full Code Here

Examples of org.myphotodiary.json.JsonObject

        getServletContext().log(
            "No directory data for: " + path, ex);
      }

      // Create Json response
      JsonObject rsp = new JsonObject();
      // Get the directory specific data
      if ((directory != null) && (directory.isIndexingAllowedBoolean())) {
        if (directory.getDescription() != null) {
          rsp.addParameter(Configuration.dirDescParam, directory.getDescription());
        }
        if (directory.getLatitude() != null) {
          rsp.addParameter(Configuration.latParam, directory.getLatitude());
        }
        if (directory.getLongitude() != null) {
          rsp.addParameter(Configuration.lngParam, directory.getLongitude());
        }
        if (directory.getDate() != null) {
          rsp.addParameter(Configuration.dirDateParam, directory.getDate());
        }
        rsp.addParameter(Configuration.groupParam,
            (directory.getGroup() == null ? Configuration.publicGroup : directory.getGroup().getGroupName()));

        List<Attribute> dirAttributes = directory.getAttributes();
        if (dirAttributes != null) {
          JsonArray attributes = new JsonArray();
          for (Attribute attribute: dirAttributes) {
            attributes.addItem(attribute.getName());
          }
          rsp.addParameter(Configuration.attrParam, attributes);
        }
      }
      else {
        rsp.addParameter(Configuration.dirDescParam, JsonEntity.NULL);
      }
      getServletContext().log("Json response: " + rsp.toString());
      // Reply the Json response
      response.setContentType(Configuration.jsonContentType);
      response.setCharacterEncoding(Configuration.contentEncoding);
      PrintWriter out = response.getWriter();
      out.print(rsp.toString());
      out.flush();
      tx.commit();
    } catch (AuthenticationException ex) {
      getServletContext().log("Unauthorized user", ex);
      tx.rollback();
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.