Search in sources :

Example 26 with Jsonb

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);
    }
}
Also used : Jsonb(jakarta.json.bind.Jsonb) JsonbConfig(jakarta.json.bind.JsonbConfig) JarOutputStream(java.util.jar.JarOutputStream) OutputStream(java.io.OutputStream) Files.newOutputStream(java.nio.file.Files.newOutputStream)

Example 27 with Jsonb

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;
}
Also used : Path(java.nio.file.Path) Jsonb(jakarta.json.bind.Jsonb) JsonbConfig(jakarta.json.bind.JsonbConfig) Files.newInputStream(java.nio.file.Files.newInputStream) InputStream(java.io.InputStream) ZpmSecurity(io.aklivity.zilla.manager.internal.settings.ZpmSecurity)

Example 28 with Jsonb

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());
}
Also used : JsonbConfig(jakarta.json.bind.JsonbConfig) Jsonb(jakarta.json.bind.Jsonb)

Example 29 with Jsonb

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);
}
Also used : JsonbConfig(jakarta.json.bind.JsonbConfig) Jsonb(jakarta.json.bind.Jsonb)

Example 30 with 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);
}
Also used : JsonbConfig(jakarta.json.bind.JsonbConfig) Jsonb(jakarta.json.bind.Jsonb) Descriptor(io.annot8.common.serialization.TestNested.Descriptor) Test(org.junit.jupiter.api.Test)

Aggregations

Jsonb (jakarta.json.bind.Jsonb)50 Test (org.junit.Test)28 JsonbConfig (jakarta.json.bind.JsonbConfig)12 Test (org.junit.jupiter.api.Test)6 InputStream (java.io.InputStream)4 Files.newInputStream (java.nio.file.Files.newInputStream)3 Path (java.nio.file.Path)3 ZpmSecurity (io.aklivity.zilla.manager.internal.settings.ZpmSecurity)2 Annot8ComponentDescriptor (io.annot8.api.components.Annot8ComponentDescriptor)2 Descriptor (io.annot8.common.serialization.TestNested.Descriptor)2 OutputStream (java.io.OutputStream)2 Files.newOutputStream (java.nio.file.Files.newOutputStream)2 ZpmCredentials (io.aklivity.zilla.manager.internal.settings.ZpmCredentials)1 ZpmSettings (io.aklivity.zilla.manager.internal.settings.ZpmSettings)1 Engine (io.aklivity.zilla.runtime.engine.Engine)1 EngineConfiguration (io.aklivity.zilla.runtime.engine.EngineConfiguration)1 BindingConfig (io.aklivity.zilla.runtime.engine.config.BindingConfig)1 NamespaceConfig (io.aklivity.zilla.runtime.engine.config.NamespaceConfig)1 RouteConfig (io.aklivity.zilla.runtime.engine.config.RouteConfig)1 VaultConfig (io.aklivity.zilla.runtime.engine.config.VaultConfig)1