public JsonImport(String jsonString, String worksheetName, Workspace workspace, String encoding, int maxNumLines) { this(JSONUtil.createJson(jsonString), worksheetName, workspace, encoding, maxNumLines); }
public JsonImport(String jsonString, RepFactory repFactory, Worksheet wk, Workspace workspace, int maxNumLines) { this(JSONUtil.createJson(jsonString), repFactory, wk, workspace, maxNumLines); }
public static String prettyPrintJson(String jsonString) { try { Object o = createJson(jsonString); if (o instanceof JSONObject) { return ((JSONObject) o).toString(4); } else if (o instanceof JSONArray) { return ((JSONArray) o).toString(4); } else { return "not JSON"; } } catch (JSONException e) { e.printStackTrace(); return "not JSON"; } }
public static Object createJson(Reader reader) { // This is an ugly, and surely inefficient solution, but I can't figure // out a way around it. String x = readerToString(reader); return createJson(x); }
output = XML.toJSONObject(responseString.toString()); } else if(entity.getContentType().toString().indexOf("json") != -1){ output = JSONUtil.createJson(responseString.toString());
private String parseChildren(String inputJSON, Workspace workspace) { JSONArray array = (JSONArray) JSONUtil.createJson(inputJSON); for (int i = 0; i < array.length(); i++) { JSONObject obj = array.getJSONObject(i); String hNodeId = obj.getString(ClientJsonKeys.id.name()); HNode node = workspace.getFactory().getHNode(hNodeId); JSONArray hNodeRepresentation = node.getJSONArrayRepresentation(workspace.getFactory()); obj.put(ClientJsonKeys.id.name(), hNodeRepresentation); if (obj.has(ClientJsonKeys.children.name())) obj.put(ClientJsonKeys.children.name(), parseChildren(obj.get(ClientJsonKeys.children.name()).toString(), workspace)); } return array.toString(); }
public XMLImport(File xmlFile, String worksheetName, Workspace workspace, String encoding, int maxNumLines, JSONArray columnsJson) { super(worksheetName, workspace, encoding); try { String fileContents = FileUtil.readFileContentsToString(xmlFile, encoding); JSONObject jsonObj = XML.toJSONObject(fileContents); Object json = JSONUtil.createJson(jsonObj.toString()); jsonImport = new JsonImport(json,this.getFactory(), this.getWorksheet(), workspace, maxNumLines); } catch (JSONException ex) { logger.error("Error in populating the worksheet with XML", ex); } catch (IOException ex) { logger.error("Error in reading the XML file", ex); } }
if(jsonFile.exists()){ json = (JSONObject) JSONUtil.createJson(new FileReader(jsonFile)); if(json == null) {
logger.info(extractions); JSONArray result = (JSONArray) JSONUtil.createJson(extractions);
@Override public Command createCommand(JSONArray inputJson, String model, Workspace workspace) throws JSONException, KarmaException { String worksheetId = CommandInputJSONUtil.getStringValue( Arguments.worksheetId.name(), inputJson); JSONArray orderedColumns = (JSONArray) JSONUtil.createJson(CommandInputJSONUtil.getStringValue( Arguments.orderedColumns.name(), inputJson)); OrganizeColumnsCommand cmd = new OrganizeColumnsCommand( getNewId(workspace), model, workspace.getId(), worksheetId, orderedColumns); cmd.setInputParameterJson(inputJson.toString()); return cmd; }
private Worksheet generateWorksheetFromJSONStream(String sourceName, InputStream is, InputProperties inputTypeParams, Workspace workspace) throws IOException { Worksheet worksheet; String encoding = (String)inputTypeParams.get(InputProperty.ENCODING); int maxNumLines = (inputTypeParams.get(InputProperty.MAX_NUM_LINES) != null)? (int)inputTypeParams.get(InputProperty.MAX_NUM_LINES) : -1; Reader reader = EncodingDetector.getInputStreamReader(is, encoding); Object json = JSONUtil.createJson(reader); JsonImport imp = new JsonImport(json, sourceName, workspace, encoding, maxNumLines); worksheet = imp.generateWorksheet(); return worksheet; } private Worksheet generateWorksheetFromAvroStream(String sourceName, InputStream is, InputProperties inputTypeParams,
inputColumns.clear(); outputColumns.clear(); Object para = JSONUtil.createJson(this.getInputParameterJson()); String addValues; HNode ndid = null; Object t = JSONUtil.createJson(addValues); if (t instanceof JSONArray) { JSONArray a = (JSONArray) t;
inputColumns.clear(); outputColumns.clear(); Object para = JSONUtil.createJson(this.getInputParameterJson()); HTable htable; if (hNodeId.compareTo("") != 0) hnodes.clear(); JSONArray checked = (JSONArray) JSONUtil.createJson(CommandInputJSONUtil.getStringValue("values", (JSONArray)para)); for (int i = 0; i < checked.length(); i++) { JSONObject t = (checked.getJSONObject(i));
JSONArray hnodes = (JSONArray) JSONUtil.createJson(inpP.getString(ClientJsonKeys.value.name())); for (int j = 0; j < hnodes.length(); j++) { JSONObject obj = (JSONObject)hnodes.get(j); } else if(HistoryJsonUtil.getParameterType(inpP) == ParameterType.orderedColumns) { Object tmp = inpP.get(ClientJsonKeys.value.name()); JSONArray hnodes = (JSONArray) JSONUtil.createJson(tmp.toString()); for (int j = 0; j < hnodes.length(); j++) { JSONObject obj = (JSONObject)hnodes.get(j);
RepFactory factory = workspace.getFactory(); Worksheet oldws = workspace.getWorksheet(worksheetId); Object para = JSONUtil.createJson(this.getInputParameterJson()); List<String> hnodeIDs = new ArrayList<>(); List<HNode> keyhnodes = new ArrayList<>(); List<HNode> valuehnodes = new ArrayList<>(); JSONArray checked = (JSONArray) JSONUtil.createJson(CommandInputJSONUtil.getStringValue("values", (JSONArray)para)); HTable ht; if (hNodeId.compareTo("") != 0)