Package net.sf.json

Examples of net.sf.json.JSONArray


 
  private static void addMethods(JSONArray methods, TASClass tClass) throws JSONException
  {
    JSONObject jTestMethod;
    TASMethod tMethod;
    JSONArray jAsserts;
    JSONObject jError;
   
    for (int i=0; i<methods.length(); i++)
    {
      jTestMethod = methods.getJSONObject(i);
View Full Code Here


   
    public void testGetAllAsJSON() throws Exception {
        JSON json = getAsJSON( "/rest/namespaces.json");
        assertTrue( json instanceof JSONObject );
       
        JSONArray namespaces = ((JSONObject)json).getJSONObject("namespaces").getJSONArray("namespace");
        assertNotNull( namespaces );
       
        assertEquals( catalog.getNamespaces().size() , namespaces.size() );
    }
View Full Code Here

   
    public void testGetAllAsJSON() throws Exception {
        JSON json = getAsJSON( "/rest/workspaces.json");
        assertTrue( json instanceof JSONObject );
       
        JSONArray workspaces = ((JSONObject)json).getJSONObject("workspaces").getJSONArray("workspace");
        assertNotNull( workspaces );
       
        assertEquals( catalog.getNamespaces().size() , workspaces.size() );
    }
View Full Code Here

    public void testGet() throws Exception
      String out = getAsString("wfs?request=GetFeature&version=1.0.0&typename=sf:PrimitiveGeoFeature&maxfeatures=1&outputformat=json");
     
      JSONObject rootObject = JSONObject.fromObject( out );
      assertEquals(rootObject.get("type"),"FeatureCollection");
      JSONArray featureCol = rootObject.getJSONArray("features");
      JSONObject aFeature = featureCol.getJSONObject(0);
      assertEquals(aFeature.getString("geometry_name"),"surfaceProperty");
    }
View Full Code Here

        String out = postAsServletResponse( "wfs", xml ).getOutputStreamContent();
     
      JSONObject rootObject = JSONObject.fromObject( out );
      assertEquals(rootObject.get("type"),"FeatureCollection");
      JSONArray featureCol = rootObject.getJSONArray("features");
      JSONObject aFeature = featureCol.getJSONObject(0);
      assertEquals(aFeature.getString("geometry_name"),"surfaceProperty");
    }
View Full Code Here

    public void testGeometryCollection() throws Exception {
      String out = getAsString("wfs?request=GetFeature&version=1.0.0&typename=sf:AggregateGeoFeature&maxfeatures=3&outputformat=json");
     
      JSONObject rootObject = JSONObject.fromObject( out );
      assertEquals(rootObject.get("type"),"FeatureCollection");
      JSONArray featureCol = rootObject.getJSONArray("features");
      JSONObject aFeature = featureCol.getJSONObject(1);
      JSONObject aGeometry = aFeature.getJSONObject("geometry");
      assertEquals(aGeometry.getString("type"),"MultiLineString");
      JSONArray geomArray = aGeometry.getJSONArray("coordinates");
      geomArray = geomArray.getJSONArray(0);
      geomArray = geomArray.getJSONArray(0);
      assertEquals(geomArray.getString(0), "55.174");
    }
View Full Code Here

        JSONObject rootObject = JSONObject.fromObject( out );
        //System.out.println(rootObject.get("type"));
        assertEquals(rootObject.get("type"),"FeatureCollection");
       
        JSONArray featureCol = rootObject.getJSONArray("features");
       
        // Check that there are at least two different types of features in here
        JSONObject aFeature = featureCol.getJSONObject(1);
        //System.out.println(aFeature.getString("id").substring(0,19));
        assertTrue(aFeature.getString("id").substring(0,19).equalsIgnoreCase("PrimitiveGeoFeature"));         
        aFeature = featureCol.getJSONObject(6);
        //System.out.println(aFeature.getString("id").substring(0,19));
        assertTrue(aFeature.getString("id").substring(0,19).equalsIgnoreCase("AggregateGeoFeature"));
              
        // Check that a feature has the expected attributes
        JSONObject aGeometry = aFeature.getJSONObject("geometry");
View Full Code Here

        // extract the json and check it
        out = out.substring(7, out.length() - 1);
        JSONObject rootObject = JSONObject.fromObject( out );
        assertEquals(rootObject.get("type"),"FeatureCollection");
        JSONArray featureCol = rootObject.getJSONArray("features");
        JSONObject aFeature = featureCol.getJSONObject(0);
        assertEquals(aFeature.getString("geometry_name"),"surfaceProperty");
    }
View Full Code Here

   * Método privado auxiliar que parsea la información de un usuario en concreto
   */
 
  private static void Usuarios(JSONObject objeto, String cuenta) throws IOException{
    if (objeto.has("http://purl.org/dc/elements/1.1/Usuario") && !cuenta.equals("cuentas")){
      JSONArray array_usuarios = objeto.getJSONArray("http://purl.org/dc/elements/1.1/Usuario");
      JSONObject objeto_usuarios = array_usuarios.getJSONObject(0);
          System.out.println("Informacion de usuario:");
          //Vamos sacando la información relevante, que son objetos, con un array, dentro de objeto_respuestas
          if(objeto_usuarios.has("http://purl.org/dc/elements/1.1/Nombre")){
            JSONArray array_user = objeto_usuarios.getJSONArray("http://purl.org/dc/elements/1.1/Nombre");
            String Nombre = array_user.getString(0);
            System.out.println("  Nombre: " + Nombre);
          }
          if(objeto_usuarios.has("http://purl.org/dc/elements/1.1/Reputacion")){
            JSONArray array_user = objeto_usuarios.getJSONArray("http://purl.org/dc/elements/1.1/Reputacion");
            String reputacion = array_user.getString(0);
            System.out.println("  Reputacion: " + reputacion);
          }
          if(objeto_usuarios.has("http://purl.org/dc/elements/1.1/MiembroDesde")){
            JSONArray array_miembro = objeto_usuarios.getJSONArray("http://purl.org/dc/elements/1.1/MiembroDesde");
            String Miembro = array_miembro.getString(0);
            System.out.println("  Miembro desde: " + Miembro);
          }
          if(objeto_usuarios.has("http://purl.org/dc/elements/1.1/VistoUltimaVez")){
            JSONArray array_visto = objeto_usuarios.getJSONArray("http://purl.org/dc/elements/1.1/VistoUltimaVez");
            String Visto = array_visto.getString(0);
            System.out.println("  Visto ultima vez: " + Visto);
          }
          if(objeto_usuarios.has("http://purl.org/dc/elements/1.1/PaginaWeb")){
            JSONArray array_web = objeto_usuarios.getJSONArray("http://purl.org/dc/elements/1.1/PaginaWeb");
            String Web = array_web.getString(0);
            System.out.println("  Pagina web: " + Web);
          }
          if(objeto_usuarios.has("http://purl.org/dc/elements/1.1/Localizacion")){
            //JSONArray array_local = objeto_usuarios.getJSONArray("http://purl.org/dc/elements/1.1/Localizacion");
            //String Localizacion = array_local.getString(0);
            //System.out.println("\nLocalización: " + Localizacion);
          }
          if(objeto_usuarios.has("http://purl.org/dc/elements/1.1/Edad")){
            JSONArray array_edad = objeto_usuarios.getJSONArray("http://purl.org/dc/elements/1.1/Edad");
            String Edad = array_edad.getString(0);
            if(Edad.contains(" ")){
              Edad.replaceAll(" ", "");
            }
            //System.out.println("\nEdad: " + Edad);
          }
          if(objeto_usuarios.has("http://purl.org/dc/elements/1.1/Descripcion")){
            JSONArray array_descript = objeto_usuarios.getJSONArray("http://purl.org/dc/elements/1.1/Descripcion");
            String Descripcion = array_descript.getString(0);
            System.out.println("  Descripcion: " + Descripcion);
          }
      if(objeto_usuarios.has("http://purl.org/dc/elements/1.1/PreguntasUsuario")){
        JSONArray array_pregunta = objeto_usuarios.getJSONArray("http://purl.org/dc/elements/1.1/PreguntasUsuario");
        JSONObject objeto_pregunta = array_pregunta.getJSONObject(0);
        if (objeto_pregunta.has("http://purl.org/dc/elements/1.1/NumeroPreguntas")){
          JSONArray array_numero = objeto_pregunta.getJSONArray("http://purl.org/dc/elements/1.1/NumeroPreguntas");
          int numero = array_numero.getInt(0);
          System.out.println("  Numero de preguntas: " + numero);
        }
        if (objeto_pregunta.has("http://purl.org/dc/elements/1.1/InformacionPreguntas")){
          JSONArray array_info = objeto_pregunta.getJSONArray("http://purl.org/dc/elements/1.1/InformacionPreguntas");
          for (int i=0;i<array_info.size();i++){
            JSONObject objeto_info = array_info.getJSONObject(i);
            if (objeto_info.has("http://purl.org/dc/elements/1.1/TituloPregunta")){
              JSONArray array_titulo = objeto_info.getJSONArray("http://purl.org/dc/elements/1.1/TituloPregunta");
              String titulo = array_titulo.getString(0);
              //System.out.println("    Titulo: " + titulo);
            }
            if (objeto_info.has("http://purl.org/dc/elements/1.1/URL")){
              JSONArray array_url = objeto_info.getJSONArray("http://purl.org/dc/elements/1.1/URL");
              String url = array_url.getString(0);
              System.out.println("    URL: " + url);
              //Launch new thread for each question with zero level!
              //new Json("0"+cuenta+url).start();
           
          }
        } 
      }
    }
    if(objeto.has("http://purl.org/dc/elements/1.1/RespuestasUsuario")){
      JSONArray array_respuestas = objeto.getJSONArray("http://purl.org/dc/elements/1.1/RespuestasUsuario");
      JSONObject objeto_respuestas = array_respuestas.getJSONObject(0);
      if (objeto_respuestas.has("http://purl.org/dc/elements/1.1/NumeroRespuestas")){
        JSONArray array_numero = objeto_respuestas.getJSONArray("http://purl.org/dc/elements/1.1/NumeroRespuestas");
        int numero = array_numero.getInt(0);
        System.out.println("  Numero de respuestas: " + numero);
      }
      if (objeto_respuestas.has("http://purl.org/dc/elements/1.1/InformacionRespuestas")){
        JSONArray array_info = objeto_respuestas.getJSONArray("http://purl.org/dc/elements/1.1/InformacionRespuestas");
        for (int i=0;i<array_info.size();i++){
          JSONObject objeto_info = array_info.getJSONObject(i);
          if (objeto_info.has("http://purl.org/dc/elements/1.1/TituloRespuesta")){
            JSONArray array_titulo = objeto_info.getJSONArray("http://purl.org/dc/elements/1.1/TituloRespuesta");
            String titulo = array_titulo.getString(0);
            //System.out.println("    Titulo ultimas resp:\n" + titulo);
          }
          if (objeto_info.has("http://purl.org/dc/elements/1.1/URL")){
            JSONArray array_url = objeto_info.getJSONArray("http://purl.org/dc/elements/1.1/URL");
            String url = array_url.getString(0);
            System.out.println("    URL: " + url);
            //Launch new thread for each last answer with zero level!           
            //new Json("0"+cuenta+url).start();
          }
        }
      }
     
    }
    if (objeto.has("http://purl.org/dc/elements/1.1/CuentasRelacionadas") && cuenta.equals("cuentas")){
      JSONArray array_cuentas = objeto.getJSONArray("http://purl.org/dc/elements/1.1/CuentasRelacionadas");
      JSONObject objeto_cuentas = array_cuentas.getJSONObject(0);
          System.out.println(" Cuentas del usuario:");
          if(objeto_cuentas.has("http://purl.org/dc/elements/1.1/URLCuentas")){
            JSONArray array_url = objeto_cuentas.getJSONArray("http://purl.org/dc/elements/1.1/URLCuentas");
            for (int i=0;i<array_url.size();i++){
              String url_cuenta = array_url.getString(i);
              System.out.println("   URL Cuenta: " + url_cuenta);
              //Launch new thread for each account with one level of !
             
              //new Json("1"+url_cuenta).start();
            }
View Full Code Here

          dameNombre = getName().replaceFirst("1", "");
          scrappy_dump = Ejecutor.executeScrappy(dameNombre, "1");
        }
        try {
          //System.out.println("Sale del comando");               
          JSONArray array = (JSONArray) JSONSerializer.toJSON(scrappy_dump);
          if(getName().contains("http://")){
            for(int i=7;i<dameNombre.indexOf("/", 7);i++){
              direccion_web += dameNombre.charAt(i);
            }
          }else{
            for(int i=0;i<dameNombre.indexOf("/");i++){
              direccion_web += dameNombre.charAt(i);
            }
          }
          for(int j=0;j<array.size();j++){
                  JSONObject objeto_dump = array.getJSONObject(j);
                  System.out.println("\n-----------------------------------------------------------------------------------------------\n");
                  System.out.println(dameNombre+"\n");
                  Usuarios(objeto_dump,direccion_web);
                  Pregunta(objeto_dump, NombreUsuario+ApellidoUsuario_Espacio);
                  Respuestas(objeto_dump, NombreUsuario+ApellidoUsuario_Espacio)
                }
        } catch(net.sf.json.JSONException e) {
          e.printStackTrace();
          System.out.println("Invalid JSON String:"+scrappy_dump);
        }
      }
      if(getName().startsWith("c")){
        url = getName().replaceFirst("c", "") + "?tab=accounts";
        scrappy_dump = Ejecutor.executeScrappy(url, "0");
        //System.out.println("DUMP:\n"+scrappy_dump);
        JSONArray array = (JSONArray) JSONSerializer.toJSON(scrappy_dump);
              for(int j=0;j<array.size();j++){
                JSONObject objeto_dump = array.getJSONObject(j);
                Usuarios(objeto_dump, "cuentas");
              }
      }
      if(getName().startsWith("s")){
        url = getName().replaceFirst("s", "");
View Full Code Here

TOP

Related Classes of net.sf.json.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.