use of com.serotonin.json.JsonWriter in project ma-core-public by infiniteautomation.
the class SampleTest method testSample.
public void testSample() throws Exception {
assertEquals(true, true);
new JsonWriter(new StringWriter()).writeObject(12);
}
use of com.serotonin.json.JsonWriter in project ma-core-public by infiniteautomation.
the class WriteTest method write.
static void write(Object o) throws Exception {
StringWriter out = new StringWriter();
JsonWriter writer = new JsonWriter(context, out);
writer.writeObject(o);
System.out.println(out);
}
use of com.serotonin.json.JsonWriter in project ma-core-public by infiniteautomation.
the class ModulesController method handleRequest.
@Override
public View handleRequest(HttpServletRequest request, HttpServletResponse response, Map<String, Object> model) throws Exception {
// Check for a license download token.
String token = request.getParameter("token");
if (!StringUtils.isEmpty(token)) {
if (downloadLicense(token))
model.put("licenseDownloaded", true);
}
List<Module> modules = ModuleRegistry.getModules();
Module.sortByName(modules);
Module core = ModuleRegistry.getCoreModule();
modules.add(0, core);
model.put("guid", Providers.get(ICoreLicense.class).getGuid());
model.put("distributor", Common.envProps.getString("distributor"));
model.put("modules", modules);
// Add in the Unloaded modules
model.put("unloadedModules", ModuleRegistry.getUnloadedModules());
// The JSON
Map<String, Object> json = new HashMap<>();
json.put("guid", Providers.get(ICoreLicense.class).getGuid());
json.put("description", SystemSettingsDao.getValue(SystemSettingsDao.INSTANCE_DESCRIPTION));
json.put("distributor", Common.envProps.getString("distributor"));
Map<String, String> jsonModules = new HashMap<>();
json.put("modules", jsonModules);
for (Module module : modules) {
jsonModules.put(module.getName(), module.getVersion().toString());
}
try {
StringWriter out = new StringWriter();
JsonWriter jsonWriter = new JsonWriter(Common.JSON_CONTEXT, out);
jsonWriter.writeObject(json);
model.put("json", out.toString());
} catch (Exception e) {
throw new ShouldNeverHappenException(e);
}
return null;
}
use of com.serotonin.json.JsonWriter in project ma-core-public by infiniteautomation.
the class AuditEventDao method writeValueAsString.
public String writeValueAsString(JsonObject value) throws JsonException, IOException {
StringWriter stringWriter = new StringWriter();
JsonWriter writer = new JsonWriter(Common.JSON_CONTEXT, stringWriter);
writer.writeObject(value);
return stringWriter.toString();
}
Aggregations