Package org.json.simple

Examples of org.json.simple.JSONArray


  protected void
  encodeResults(
    Subscription  subs,
    Map        result )
  {
    JSONArray  results_list = new JSONArray();
   
    SubscriptionResult[]  results = subs.getHistory().getResults( false );
   
    for(int i=0; i<results.length; i++){
     
      SubscriptionResult r = results[i];
     
      results_list.add( r.toJSONMap());
    }
   
    result.put( "results", results_list );
   
   
View Full Code Here


    FieldMapping[] mappings = getMappings();

    try {
      Object jsonObject = JSONValue.parse(page);
     
      JSONArray resultArray = null;
     
      if(resultsEntryPath != null) {
        StringTokenizer st = new StringTokenizer(resultsEntryPath,".");
        if(jsonObject instanceof JSONArray && st.countTokens() > 0) {
          JSONArray array = (JSONArray) jsonObject;
          if(array.size() == 1) {
            jsonObject = array.get(0);
          }
        }
        while(st.hasMoreTokens()) {
          try {
            jsonObject = ((JSONObject)jsonObject).get(st.nextToken());
View Full Code Here

    if ( !automaticDateParser ){
     
      ImportExportUtils.exportJSONString( res, "time_format",  userDateFormat );
    }
   
    JSONArray  maps = new JSONArray();
   
    res.put( "column_map", maps );

    for (int i=0;i<mappings.length;i++){
     
      FieldMapping fm = mappings[i];
     
      int  field_id = fm.getField();
     
      String  field_value = vuzeIDToField( field_id );
     
      if ( field_value == null ){
       
        log( "JSON export: unknown field id " + field_id );
       
      }else{
             
        JSONObject entry = new JSONObject();

        maps.add( entry );
         
        entry.put( "vuze_field", field_value );
       
        if ( getType() == ENGINE_TYPE_JSON ){
         
View Full Code Here

      int  from_field  = remapper.getInField();
      //int  to_field  = remapper.getOutField();
     
      String from_field_str = vuzeIDToField( from_field );
     
      JSONArray  mappings = new JSONArray();
     
      field_map.put( from_field_str, mappings );
     
      FieldRemapping[] frs = remapper.getMappings();
     
      for (int j=0;j<frs.length;j++){
       
        FieldRemapping fr = frs[j];
       
        String from_str = UrlUtils.encode( fr.getMatchString());
       
        String to_str  = fr.getReplacement();
       
        JSONObject map = new JSONObject();
       
        mappings.add( map );
       
        map.put( level_1?"from_string":"cat_string", from_str );
        map.put( level_1?"to_string":"media_type", to_str );
      }
    }
View Full Code Here

  {
    checkEnabled( OP_GET_SUBS_BY_SID );
   
    Map parameters = new HashMap();
   
    List  sid_list = new JSONArray();

    sid_list.add( Base32.encode( sid ));
   
    parameters.put( "subscription_ids", sid_list);
   
    Map reply = dispatcher.syncInvokeOP_GET_SUBS_BY_SID, parameters );

    for (int i=0;i<sid_list.size();i++){
     
      Map  map = (Map)reply.get((String)sid_list.get(i));
     
      if ( map != null ){
       
        subscriptionDetails details = new subscriptionDetails( map );
       
View Full Code Here

  {
    checkEnabled( OP_GET_POP_BY_SID );
   
    Map parameters = new HashMap();
   
    List  sid_list = new JSONArray();
   
    sid_list.add( Base32.encode( sid ));
         
    parameters.put( "subscription_ids", sid_list );
   
    Map reply = dispatcher.syncInvokeOP_GET_POP_BY_SID, parameters );
   
    for (int i=0;i<sid_list.size();i++){
     
      Map  map = (Map)reply.get((String)sid_list.get(i));
     
      if ( map != null ){
       
        subscriptionInfo info = new subscriptionInfo( map );
       
View Full Code Here

  {
    checkEnabled( OP_SET_SELECTED );
   
    Map parameters = new HashMap();
   
    List  sid_list   = new JSONArray();   
    for (int i=0;i<sids.size();i++){
   
      sid_list.add( Base32.encode( (byte[])sids.get(i) ));
    }
   
    parameters.put( "subscription_ids", sid_list);
   
    Map reply = dispatcher.syncInvoke( OP_SET_SELECTED, parameters );
View Full Code Here

    String    key,
    String[]  data )
 
    throws IOException
  {
    List  l = new JSONArray(data.length);
   
    map.put( key, l );
   
    for (int i=0;i<data.length;i++){
     
      l.add( data[i] );
    }
  }
View Full Code Here

            valueStack.push(new JSONObject());
            break;
          case Yytoken.TYPE_LEFT_SQUARE:
            status=S_IN_ARRAY;
            statusStack.push(new Integer(status));
            valueStack.push(new JSONArray());
            break;
          default:
            status=S_IN_ERROR;
          }//inner switch
          break;
         
        case S_IN_FINISHED_VALUE:
          if(token.type==Yytoken.TYPE_EOF)
            return valueStack.pop();
          else
            return null;
         
        case S_IN_OBJECT:
          switch(token.type){
          case Yytoken.TYPE_COMMA:
            break;
          case Yytoken.TYPE_VALUE:
            if(token.value instanceof String){
              String key=(String)token.value;
              valueStack.push(key);
              status=S_PASSED_PAIR_KEY;
              statusStack.push(new Integer(status));
            }
            else{
              status=S_IN_ERROR;
            }
            break;
          case Yytoken.TYPE_RIGHT_BRACE:
            if(valueStack.size()>1){
              statusStack.pop();
              JSONObject map = (JSONObject)valueStack.pop();
              map.compactify(-0.9f);
              status=peekStatus(statusStack);
            }
            else{
              status=S_IN_FINISHED_VALUE;
            }
            break;
          default:
            status=S_IN_ERROR;
            break;
          }//inner switch
          break;
         
        case S_PASSED_PAIR_KEY:
          switch(token.type){
          case Yytoken.TYPE_COLON:
            break;
          case Yytoken.TYPE_VALUE:
            statusStack.pop();
            String key=(String)valueStack.pop();
            JSONObject parent=(JSONObject)valueStack.peek();
            parent.put(key,token.value);
            status=peekStatus(statusStack);
            break;
          case Yytoken.TYPE_LEFT_SQUARE:
            statusStack.pop();
            key=(String)valueStack.pop();
            parent=(JSONObject)valueStack.peek();
            JSONArray newArray=new JSONArray();
            parent.put(key,newArray);
            status=S_IN_ARRAY;
            statusStack.push(new Integer(status));
            valueStack.push(newArray);
            break;
          case Yytoken.TYPE_LEFT_BRACE:
            statusStack.pop();
            key=(String)valueStack.pop();
            parent=(JSONObject)valueStack.peek();
            JSONObject newObject=new JSONObject();
            parent.put(key,newObject);
            status=S_IN_OBJECT;
            statusStack.push(new Integer(status));
            valueStack.push(newObject);
            break;
          default:
            status=S_IN_ERROR;
          }
          break;
         
        case S_IN_ARRAY:
          switch(token.type){
          case Yytoken.TYPE_COMMA:
            break;
          case Yytoken.TYPE_VALUE:
            JSONArray val=(JSONArray)valueStack.peek();
            val.add(token.value);
            break;
          case Yytoken.TYPE_RIGHT_SQUARE:
            if(valueStack.size()>1){
              statusStack.pop();
              valueStack.pop();
              status=peekStatus(statusStack);
            }
            else{
              status=S_IN_FINISHED_VALUE;
            }
            break;
          case Yytoken.TYPE_LEFT_BRACE:
            val=(JSONArray)valueStack.peek();
            JSONObject newObject=new JSONObject();
            val.add(newObject);
            status=S_IN_OBJECT;
            statusStack.push(new Integer(status));
            valueStack.push(newObject);
            break;
          case Yytoken.TYPE_LEFT_SQUARE:
            val=(JSONArray)valueStack.peek();
            JSONArray newArray=new JSONArray();
            val.add(newArray);
            status=S_IN_ARRAY;
            statusStack.push(new Integer(status));
            valueStack.push(newArray);
            break;
View Full Code Here

   * @return
   *
   * @since 3.0.1.5
   */
  private static List encodeToJSONArray(Collection list) {
    List newList = new JSONArray(list);

    for (int i = 0; i < newList.size(); i++) {
      Object value = newList.get(i);

      newList.set(i, coerce(value));
    }

    return newList;
  }
View Full Code Here

TOP

Related Classes of org.json.simple.JSONArray

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.