public void writeTo(DeviceInfo deviceInfo, JsonGenerator gen) {
        JsonWriter writer = new JsonWriter(gen);
        gen.writeStartObject();
        gen.write("dicomDeviceName", deviceInfo.getDeviceName());
        writer.writeNotNullOrDef("dicomDescription", deviceInfo.getDescription(), null);
        writer.writeNotNullOrDef("dicomManufacturer", deviceInfo.getManufacturer(), null);
        writer.writeNotNullOrDef("dicomManufacturerModelName", deviceInfo.getManufacturerModelName(), null);
        writer.writeNotEmpty("dicomSoftwareVersion", deviceInfo.getSoftwareVersions());
        writer.writeNotNullOrDef("dicomStationName", deviceInfo.getStationName(), null);
        writer.writeNotEmpty("dicomInstitutionName", deviceInfo.getInstitutionNames());
        writer.writeNotEmpty("dicomInstitutionDepartmentName", deviceInfo.getInstitutionalDepartmentNames());
        writer.writeNotEmpty("dicomPrimaryDeviceType", deviceInfo.getPrimaryDeviceTypes());
        gen.write("dicomInstalled", deviceInfo.getInstalled());
        gen.write("hasArcDevExt", deviceInfo.getArcDevExt());
        gen.writeEnd();
    }
@Test
    public void testWriteTo() throws Exception {
        StringWriter writer = new StringWriter();
        try ( JsonGenerator gen = Json.createGenerator(writer)) {
            JsonConfiguration config = new JsonConfiguration();
            config.addJsonConfigurationExtension(new JsonAuditLoggerConfiguration());
            config.addJsonConfigurationExtension(new JsonAuditRecordRepositoryConfiguration());
            config.addJsonConfigurationExtension(new JsonImageReaderConfiguration());
            config.addJsonConfigurationExtension(new JsonImageWriterConfiguration());
            config.addJsonConfigurationExtension(new JsonHL7Configuration());
            config.writeTo(createDevice("Test-Device-1", "TEST-AET1"), gen, true);
        }
        Path path = Paths.get("src/test/data/device.json");
//        try (BufferedWriter w = Files.newBufferedWriter(path, Charset.forName("UTF-8"))) {
//            w.write(writer.toString());
//        }
        try (BufferedReader reader = Files.newBufferedReader(path, Charset.forName("UTF-8"))) {
            assertEquals(reader.readLine(), writer.toString());
        }
    }