use of jakarta.json.bind.Jsonb in project zilla by aklivity.
the class ZpmInstall method writeLockFile.
private void writeLockFile(ZpmConfiguration config, Path lockFile) throws IOException {
Jsonb builder = JsonbBuilder.newBuilder().withConfig(new JsonbConfig().withFormatting(true)).build();
createDirectories(lockDir);
try (OutputStream out = newOutputStream(lockFile)) {
builder.toJson(config, out);
}
}
use of jakarta.json.bind.Jsonb in project zilla by aklivity.
the class ZpmEncrypt method readSecurity.
private ZpmSecurity readSecurity(Path settingsDir) throws IOException, PlexusCipherException {
Path securityFile = settingsDir.resolve("security.json");
ZpmSecurity security = new ZpmSecurity();
Jsonb builder = JsonbBuilder.newBuilder().withConfig(new JsonbConfig().withFormatting(true)).build();
if (Files.exists(securityFile)) {
try (InputStream in = newInputStream(securityFile)) {
security = builder.fromJson(in, ZpmSecurity.class);
}
}
return security;
}
use of jakarta.json.bind.Jsonb in project alias by JohT.
the class TypeReferenceEnhancementIntegrationTest method serializeAndDeserialize.
@SuppressWarnings("unchecked")
private <T> T serializeAndDeserialize(T object) {
JsonbConfig config = new TestJsonbConfigProvider().getJsonbConfig();
Jsonb jsonb = JsonbBuilder.create(config);
String json = printed(jsonb.toJson(object));
return (T) jsonb.fromJson(json, object.getClass());
}
use of jakarta.json.bind.Jsonb in project helidon by oracle.
the class JsonbProvider method create.
@Override
public MediaSupport create(Config config) {
JsonbConfig jsonbConfig = new JsonbConfig();
config.asMap().ifPresent(map -> map.forEach(jsonbConfig::setProperty));
Jsonb jsonb = JsonbBuilder.create(jsonbConfig);
return JsonbSupport.create(jsonb);
}
use of jakarta.json.bind.Jsonb in project annot8 by annot8.
the class Annot8ComponentDescriptorSerializerTest method testNested.
@Test
public void testNested() {
JsonbConfig config = new JsonbConfig().withSerializers(new Annot8ComponentDescriptorSerializer());
Jsonb jb = JsonbBuilder.create(config);
Descriptor desc = new Descriptor();
String json = jb.toJson(desc);
assertEquals("{\"io.annot8.common.serialization.TestNested$Descriptor\":{\"name\":\"\",\"settings\":{}}}", json);
}
Aggregations