Package edu.isi.karma.imp.json

Examples of edu.isi.karma.imp.json.JsonImport


    FileReader r;
    try {
      r = new FileReader(fileName);
      Object o = JSONUtil.createJson(r);
      File f = new File(fileName);
      JsonImport ji = new JsonImport(o, f.getName(), workspace, "UTF-8", -1);
      Worksheet w = ji.generateWorksheet();
      return w;
    } catch (FileNotFoundException e) {
      logger.error("Cannot read file " + fileName + ".");
      e.printStackTrace();
    } catch (JSONException e) {
View Full Code Here


    File xmlFile = new File(fileName);
    try {
      String fileContents = FileUtil.readFileContentsToString(xmlFile, "UTF-8");
      // Converting the XML to JSON
      JSONObject json = XML.toJSONObject(fileContents);
      JsonImport ji = new JsonImport(json, fileName, workspace, "UTF-8", -1);
      Worksheet w = ji.generateWorksheet();
      return w;
    } catch (FileNotFoundException e) {
      logger.error("Cannot read file " + fileName + ".");
      e.printStackTrace();
    } catch (JSONException e) {
View Full Code Here

  public static Worksheet createWorksheetFromJsonString(String name,
      String jsonString, Workspace workspace) {
    try {
      Object o = JSONUtil.createJson(jsonString);
      JSONUtil.writeJsonFile(o, name + ".json");
      JsonImport ji = new JsonImport(o, name, workspace, "UTF-8", -1);
      Worksheet w = ji.generateWorksheet();
      return w;
    } catch (JSONException e) {
      e.printStackTrace();
      return null;
    }
View Full Code Here

  }

  public static Worksheet createSampleJson(Workspace workspace, int numRows) {
    try {
      Object o = JSONUtil.createJson(getSampleJsonString(numRows));
      JsonImport ji = new JsonImport(o, "Sample JSON", workspace, "UTF-8", -1);
      Worksheet w = ji.generateWorksheet();
      return w;
    } catch (JSONException e) {
      e.printStackTrace();
      return null;
    }
View Full Code Here

          .value("there is a tab between \"x\" and \"y\": x\ty")
          .key("newlines").value("there sho\nuld be a newline")
          .key("HTML").value(html).key("URL").value("http://cnn.com")
          .endObject();

      JsonImport ji = new JsonImport(x.toString(),
          "Funny Characters", workspace, "UTF-8", -1);
      Worksheet w = ji.generateWorksheet();
      return w;
    } catch (JSONException e) {
      e.printStackTrace();
      return null;
    }
View Full Code Here

      topA.object().key("a").value("a_2").endObject();

      topA.endArray();

      JsonImport ji = new JsonImport(x.toString(),
          "Empty Nested Table 1", workspace, "UTF-8", -1);
      Worksheet w = ji.generateWorksheet();
      return w;
    } catch (JSONException e) {
      e.printStackTrace();
      return null;
    }
View Full Code Here

      topA.object().key("a").value("a_2").endObject();

      topA.endArray();

      JsonImport ji = new JsonImport(x.toString(),
          "Empty Nested Table 2", workspace, "UTF-8", -1);
      Worksheet w = ji.generateWorksheet();
      return w;
    } catch (JSONException e) {
      e.printStackTrace();
      return null;
    }
View Full Code Here

      topA.object().key("b").array().endArray().endObject();

      topA.endArray();

      JsonImport ji = new JsonImport(x.toString(),
          "Empty Nested Table 3", workspace, "UTF-8", -1);
      Worksheet w = ji.generateWorksheet();
      return w;
    } catch (JSONException e) {
      e.printStackTrace();
      return null;
    }
View Full Code Here

      topA.object().key("a").value("a_2").endObject();

      topA.endArray();

      JsonImport ji = new JsonImport(x.toString(),
          "Empty Nested Table 4", workspace, "UTF-8", -1);
      Worksheet w = ji.generateWorksheet();
      return w;
    } catch (JSONException e) {
      e.printStackTrace();
      return null;
    }
View Full Code Here

          //
          .endArray().endObject();

      topA.endArray();

      JsonImport ji = new JsonImport(x.toString(),
          "Nested Table 1", workspace, "UTF-8", -1);
      Worksheet w = ji.generateWorksheet();
      return w;
    } catch (JSONException e) {
      e.printStackTrace();
      return null;
    }
View Full Code Here

TOP

Related Classes of edu.isi.karma.imp.json.JsonImport

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.