org.apache.juneau.json.JsonSerializer.builder()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(5.3k)|赞(0)|评价(0)|浏览(127)

本文整理了Java中org.apache.juneau.json.JsonSerializer.builder()方法的一些代码示例,展示了JsonSerializer.builder()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonSerializer.builder()方法的具体详情如下:
包路径:org.apache.juneau.json.JsonSerializer
类名称:JsonSerializer
方法名:builder

JsonSerializer.builder介绍

暂无

代码示例

代码示例来源:origin: apache/juneau

/**
 * Returns the schema serializer based on the settings of this serializer.
 *
 * <p>
 * Note that this method creates a builder initialized to all default settings, whereas {@link #builder()} copies
 * the settings of the object called on.
 *
 * @return The schema serializer.
 */
public JsonSchemaSerializer getSchemaSerializer() {
  if (schemaSerializer == null)
    schemaSerializer = builder().build(JsonSchemaSerializer.class);
  return schemaSerializer;
}

代码示例来源:origin: apache/juneau

/**
 * Returns the schema serializer based on the settings of this serializer.
 *
 * <p>
 * Note that this method creates a builder initialized to all default settings, whereas {@link #builder()} copies
 * the settings of the object called on.
 *
 * @return The schema serializer.
 */
public JsonSchemaSerializer getSchemaSerializer() {
  if (schemaSerializer == null)
    schemaSerializer = builder().build(JsonSchemaSerializer.class);
  return schemaSerializer;
}

代码示例来源:origin: org.apache.juneau/juneau-marshall

/**
 * Returns the schema serializer based on the settings of this serializer.
 *
 * <p>
 * Note that this method creates a builder initialized to all default settings, whereas {@link #builder()} copies
 * the settings of the object called on.
 *
 * @return The schema serializer.
 */
public JsonSchemaSerializer getSchemaSerializer() {
  if (schemaSerializer == null)
    schemaSerializer = builder().build(JsonSchemaSerializer.class);
  return schemaSerializer;
}

代码示例来源:origin: apache/juneau

@Test
  public void testComparison() throws Exception {
    List<UrlPathPattern> l = new LinkedList<>();

    l.add(new UrlPathPattern("/foo"));
    l.add(new UrlPathPattern("/foo/*"));
    l.add(new UrlPathPattern("/foo/bar"));
    l.add(new UrlPathPattern("/foo/bar/*"));
    l.add(new UrlPathPattern("/foo/{id}"));
    l.add(new UrlPathPattern("/foo/{id}/*"));
    l.add(new UrlPathPattern("/foo/{id}/bar"));
    l.add(new UrlPathPattern("/foo/{id}/bar/*"));

    Collections.sort(l);
    assertEquals("[{patternString:'/foo/bar',vars:[]},{patternString:'/foo/bar/*',vars:[]},{patternString:'/foo/{id}/bar',vars:['id']},{patternString:'/foo/{id}/bar/*',vars:['id']},{patternString:'/foo/{id}',vars:['id']},{patternString:'/foo/{id}/*',vars:['id']},{patternString:'/foo',vars:[]},{patternString:'/foo/*',vars:[]}]", SimpleJsonSerializer.DEFAULT.builder().sortProperties().build().serialize(l));
  }
}

代码示例来源:origin: apache/streams

.build())
.serializer(
  JsonSerializer.DEFAULT.builder()
    .pojoSwaps(JodaDateSwap.class)
    .build())

代码示例来源:origin: apache/juneau

@Test
public void a1_serializeJson() throws Exception {
  WriterSerializer s = SimpleJsonSerializer.DEFAULT_READABLE.builder().maxIndent(input.maxDepth).build();
  testSerialize("json", s, input.json);
}

代码示例来源:origin: apache/juneau

@Test
public void testSubTypeWithGenerics() throws Exception {
  JsonSerializer s = JsonSerializer.DEFAULT.builder().addBeanTypes().addRootType().build();
  C1 c1 = C3.create();
  String r = s.serialize(c1);
  assertEquals("{\"_type\":\"C3\",\"f1\":{\"f2\":\"f2\",\"f3\":3}}", r);
}

代码示例来源:origin: apache/juneau

public ConfigInterfaceTest() throws Exception {
  cf = Config.create().serializer(SimpleJsonSerializer.DEFAULT.builder().addBeanTypes().addRootType().build()).build();
  proxy = cf.getSectionAsInterface("A", ConfigInterface.class);
}

代码示例来源:origin: apache/streams

private FullContact(FullContactConfiguration configuration) throws InstantiationException {
 this.configuration = configuration;
 this.parser = JsonParser.DEFAULT.builder()
  .ignoreUnknownBeanProperties(true)
  .build();
 this.serializer = JsonSerializer.DEFAULT.builder()
  .trimEmptyCollections(true)
  .trimEmptyMaps(true)
  .build();
 this.restClientBuilder = RestClient.create()
  .accept("application/json")
  .contentType("application/json")
  .disableAutomaticRetries()
  .disableCookieManagement()
  .disableRedirectHandling()
  .header("Authorization", "Bearer "+configuration.getToken())
  .parser(parser)
  .serializer(serializer)
  .rootUrl(baseUrl());
 this.restClient = restClientBuilder.build();
}

代码示例来源:origin: apache/juneau

@Test
public void testSubTypes() throws Exception {
  JsonSerializer s = SimpleJsonSerializer.DEFAULT.builder().addBeanTypes().addRootType().build();
  JsonParser p = JsonParser.DEFAULT;
  A1 a1 = new A1();
  a1.f1 = "f1";
  a1.fb = new B2();
  ((B2)a1.fb).f2 = "f2";
  String r = s.serialize(a1);
  assertEquals("{_type:'A1',f0:'f0',fb:{_type:'B2',f0b:'f0b',f2:'f2'},f1:'f1'}", r);
  A a = p.parse(r, A.class);
  assertTrue(a instanceof A1);
  assertTrue(a.fb instanceof B2);
  assertEquals("f1", ((A1)a).f1);
  assertEquals("f2", ((B2)a.fb).f2);
  // Try out-of-order creation.
  r = "{f0:'f0',f1:'f1',_type:'A1',fb:{f0b:'f0b',f2:'f2',_type:'B2'}}";
  a = p.parse(r, A.class);
  assertTrue(a instanceof A1);
  assertTrue(a.fb instanceof B2);
  assertEquals("f1", ((A1)a).f1);
  assertEquals("f2", ((B2)a.fb).f2);
}

代码示例来源:origin: apache/juneau

assertEquals("city B", a3.city);
serializer = SimpleJsonSerializer.DEFAULT.builder().addBeanTypes().addRootType().build();
p = new Person("some name", 123,
  new Address("street A", "city A", "state A", 12345, true),

相关文章