use of dontweave.gson.JsonParser in project h2o-2 by h2oai.
the class WebAPI method exportModel.
/**
* Exports a model to a JSON file.
*/
static void exportModel() throws Exception {
HttpClient client = new HttpClient();
GetMethod get = new GetMethod(URL + "/2/ExportModel.json?model=MyInitialNeuralNet");
int status = client.executeMethod(get);
if (status != 200)
throw new Exception(get.getStatusText());
JsonObject response = (JsonObject) new JsonParser().parse(new InputStreamReader(get.getResponseBodyAsStream()));
JsonElement model = response.get("model");
JsonWriter writer = new JsonWriter(new FileWriter(JSON_FILE));
writer.setLenient(true);
writer.setIndent(" ");
Streams.write(model, writer);
writer.close();
get.releaseConnection();
}
use of dontweave.gson.JsonParser in project h2o-2 by h2oai.
the class ModelMetrics method toJSON.
public JsonObject toJSON() {
final String json = new String(writeJSON(new AutoBuffer()).buf());
if (json.length() == 0)
return new JsonObject();
JsonObject jo = (JsonObject) new JsonParser().parse(json);
if (jo.has("model"))
jo.getAsJsonObject("model").addProperty("model_category", this.model_category.toString());
return jo;
}
use of dontweave.gson.JsonParser in project h2o-2 by h2oai.
the class Request2 method toJSON.
public JsonObject toJSON() {
final String json = new String(writeJSON(new AutoBuffer()).buf());
if (json.length() == 0)
return new JsonObject();
JsonObject jo = (JsonObject) new JsonParser().parse(json);
jo.remove("Request2");
jo.remove("response_info");
return jo;
}
use of dontweave.gson.JsonParser in project h2o-2 by h2oai.
the class UniqueFrameId method toJSON.
public JsonObject toJSON() {
final String json = new String(writeJSON(new AutoBuffer()).buf());
if (json.length() == 0)
return new JsonObject();
JsonObject jo = (JsonObject) new JsonParser().parse(json);
jo.addProperty("id", this.getId());
return jo;
}
Aggregations