List of usage examples for org.json.simple JSONValue parse
public static Object parse(String s)
From source file:ch.simas.jtoggl.Workspace.java
public Workspace(String jsonString) { JSONObject object = (JSONObject) JSONValue.parse(jsonString); this.id = (Long) object.get("id"); this.name = (String) object.get("name"); this.premium = (Boolean) object.get("premium"); }
From source file:net.jakobnielsen.imagga.upload.convert.UploadConverter.java
@Override public String convert(String jsonString) { if (jsonString == null) { throw new ConverterException("The given JSON string is null"); }/*from www. j ava 2s . c o m*/ JSONObject json = (JSONObject) JSONValue.parse(jsonString); if (!json.containsKey(UPLOAD_FOR_PROCESSING)) { throw new ConverterException(UPLOAD_FOR_PROCESSING + " key missing from json : " + jsonString); } JSONObject json2 = (JSONObject) json.get(UPLOAD_FOR_PROCESSING); return json2.get("upload_code").toString(); }
From source file:net.bitnine.agensgraph.graph.property.JsonObject.java
public JsonObject(String s) { props = (JSONObject) JSONValue.parse(s); if (props == null) throw new IllegalArgumentException("invalid json object format string"); setJsonValue(this); }
From source file:capstone.yelpmodel.JSONWrapper.java
public JSONWrapper(File f) { try {/*from w w w . ja va 2 s . c o m*/ String src = "["; FileInputStream fis = new FileInputStream(f); InputStreamReader isr = new InputStreamReader(fis); BufferedReader br = new BufferedReader(isr); int count = 0; while (br.ready() && count < MAX_RECORDS) { String line = br.readLine(); src += line + ",\n"; count++; } src += "]"; json = (JSONArray) JSONValue.parse(src); } catch (Exception e) { System.out.println(e); } }
From source file:net.bitnine.agensgraph.graph.property.JsonArray.java
public JsonArray(String s) { array = (JSONArray) JSONValue.parse(s); if (array == null) throw new IllegalArgumentException("invalid json array format string"); setJsonValue(this); }
From source file:com.p000ison.dev.simpleclans2.util.JSONUtil.java
public static List<String> JSONToStringList(String json) { if (json == null || json.isEmpty()) { return null; }// ww w . j av a 2s . c o m JSONArray parser = (JSONArray) JSONValue.parse(json); if (parser == null) { return null; } List<String> list = new ArrayList<String>(); for (Object obj : parser) { list.add(obj.toString()); } return list; }
From source file:dimensionsorter.DimensionSorter.java
/** * @param args the command line arguments *///from w w w.j a v a2s . c om public static void sortDimensions() { CloudQueueMessage message = schedulerQueue.retrieveMessage(); if (message != null) { schedulerQueue.deleteMessage(message); String json = message.getMessageContentAsString(); Object obj = JSONValue.parse(json); JSONObject jsonObject = (JSONObject) obj; datasetName = (String) jsonObject.get("dataset"); double[] image_descritor_vector = (double[]) jsonObject.get("im_d_v"); double[] priority_index = (double[]) jsonObject.get("p_i"); double[] sorted_i_d_v = new double[image_descritor_vector.length]; for (int i = 0; i < priority_index.length; i++) { sorted_i_d_v[i] = (double) image_descritor_vector[priority_index[i]]; } //Send message to the Image Sorter to retrieve the numberOfImageSorterNodes L^{(m)} initializeImageSorter(); } }
From source file:net.maxgigapop.mrs.driver.openstack.OpenStackRESTClient.java
public static String getTenantId(String host, String tenantName, String token) throws IOException { String url = String.format("http://%s:35357/v2.0/tenants", host); URL obj = new URL(url); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); String responseStr = sendGET(obj, con, "python-keystoneclient", token); //System.out.println(responseStr); JSONObject responseJSON = (JSONObject) JSONValue.parse(responseStr); JSONArray tenants = (JSONArray) responseJSON.get("tenants"); String tenantId = ""; for (Object tenant : tenants) { if (((JSONObject) tenant).get("name").equals(tenantName)) { tenantId = (String) ((JSONObject) tenant).get("id"); }/*from w w w .ja va2 s .c o m*/ } return tenantId; }
From source file:ch.simas.jtoggl.ProjectUser.java
public ProjectUser(String jsonString) { JSONObject object = (JSONObject) JSONValue.parse(jsonString); this.id = (Long) object.get("id"); this.hourly_rate = (Double) object.get("rate"); this.manager = (Boolean) object.get("manager"); JSONObject projectObject = (JSONObject) object.get("project"); if (projectObject != null) { this.project = new Project(projectObject.toJSONString()); }/*from www.ja v a2 s .c o m*/ JSONObject userObject = (JSONObject) object.get("user"); if (userObject != null) { this.user = new User(userObject.toJSONString()); } }
From source file:ch.simas.jtoggl.Client.java
public Client(String jsonString) { JSONObject object = (JSONObject) JSONValue.parse(jsonString); this.id = (Long) object.get("id"); this.name = (String) object.get("name"); Object hrate = object.get("hrate"); if (hrate != null) { this.hourly_rate = hrate.toString(); }/*from w ww .j av a 2 s . co m*/ this.currency = (String) object.get("cur"); this.notes = (String) object.get("notes"); JSONObject workspaceObject = (JSONObject) object.get("workspace"); if (workspaceObject != null) { this.workspace = new Workspace(workspaceObject.toJSONString()); } }