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

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

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

JsonSerializer.toString介绍

暂无

代码示例

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

@Override /* Object */
  public String toString() {
    return SimpleJsonSerializer.DEFAULT.toString(this);
  }
}

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

@Override /* Object */
  public String toString() {
    return JsonSerializer.DEFAULT.toString(this);
  }
}

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

@Override /* Object */
  public String toString() {
    return SimpleJsonSerializer.DEFAULT.toString(this);
  }
}

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

@Override /* Object */
  public String toString() {
    return SimpleJsonSerializer.DEFAULT.toString(this);
  }
}

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

@Override /* Object */
  public String toString() {
    return SimpleJsonSerializer.DEFAULT.toString(this);
  }
}

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

@Override /* Object */
  public String toString() {
    return JsonSerializer.DEFAULT.toString(this);
  }
}

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

@Override /* Object */
  public String toString() {
    return JsonSerializer.DEFAULT.toString(this);
  }
}

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

@Override /* Object */
  public String toString() {
    return JsonSerializer.DEFAULT.toString(this);
  }
}

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

@Override /* Object */
  public String toString() {
    return JsonSerializer.DEFAULT.toString(this);
  }
}

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

@Override /* Object */
  public String toString() {
    return SimpleJsonSerializer.DEFAULT.toString(this);
  }
}

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

@Override /* Object */
  public String toString() {
    return JsonSerializer.DEFAULT.toString(this);
  }
}

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

private static String getMessage(SerializerSession session, String msg, Object... args) {
  msg = format(msg, args);
  if (session != null) {
    Map<String,Object> m = session.getLastLocation();
    if (m != null && ! m.isEmpty())
      msg = "Serialize exception occurred at " + SimpleJsonSerializer.DEFAULT.toString(m) + ".  " + msg;
  }
  return msg;
}

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

private static String getMessage(SerializerSession session, String msg, Object... args) {
  msg = format(msg, args);
  if (session != null) {
    Map<String,Object> m = session.getLastLocation();
    if (m != null && ! m.isEmpty())
      msg = "Serialize exception occurred at " + SimpleJsonSerializer.DEFAULT.toString(m) + ".  " + msg;
  }
  return msg;
}

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

private void testParse(Serializer s, Parser p) throws Exception {
  try {
    String r = s.serializeToString(new TestURI());
    TreeMap<String,String> m = p.parse(r, TreeMap.class, String.class, String.class);
    String r2 = SimpleJsonSerializer.DEFAULT.toString(m);
    TestUtils.assertEquals(results.json, r2, "{0}/{1} parse failed", label, s.getClass().getSimpleName());
  } catch (AssertionError e) {
    throw e;
  } catch (Exception e) {
    e.printStackTrace();
    throw new AssertionError(label + "/" + s.getClass().getSimpleName() + " failed.  exception=" + e.getLocalizedMessage());
  }
}

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

@Test
  public void test() throws Exception {
    assertEquals("{c:'c',a:'a'}", SimpleJsonSerializer.DEFAULT.toString(new A()));
  }
}

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

@Test
public void testGetPublicMethods() throws Exception {
  PojoRest model = new PojoRest(new AddressBook().init());
  assertTrue(SimpleJsonSerializer.DEFAULT.toString(model.getPublicMethods("0")).contains("'toString'"));
  assertTrue(SimpleJsonSerializer.DEFAULT.toString(model.getPublicMethods("0/addresses/0/state")).contains("'toString'"));
  assertNull(model.getPublicMethods("1"));
}

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

@RestMethod(name=POST, path="/*")
public Reader formPostAsContent(
    @Body F01 bean,
    @HasQuery("p1") boolean hqp1, @HasQuery("p2") boolean hqp2,
    @Query("p1") String qp1, @Query("p2") int qp2) throws Exception {
  return new StringReader("bean=["+SimpleJsonSerializer.DEFAULT.toString(bean)+"],qp1=["+qp1+"],qp2=["+qp2+"],hqp1=["+hqp1+"],hqp2=["+hqp2+"]");
}
public static class F01 {

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

@Test
public void e03_complexPojos_C_body() throws Exception {
  String expected = "{f01:['a','b'],f02:['c','d'],f03:[1,2],f04:[3,4],f05:[['e','f'],['g','h']],f06:[['i','j'],['k','l']],f07:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f08:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f09:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f10:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f11:['a','b'],f12:['c','d'],f13:[1,2],f14:[3,4],f15:[['e','f'],['g','h']],f16:[['i','j'],['k','l']],f17:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f18:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f19:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f20:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]]}";
  e.put("/C", SimpleJsonSerializer.DEFAULT.toString(DTOs.B.INSTANCE)).json().execute().assertBody(expected);
}
@Test

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

@Test
public void e01_complexPojos_B_body() throws Exception {
  String expected = "{f01:['a','b'],f02:['c','d'],f03:[1,2],f04:[3,4],f05:[['e','f'],['g','h']],f06:[['i','j'],['k','l']],f07:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f08:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f09:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f10:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f11:['a','b'],f12:['c','d'],f13:[1,2],f14:[3,4],f15:[['e','f'],['g','h']],f16:[['i','j'],['k','l']],f17:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f18:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f19:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f20:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]]}";
  e.put("/B", SimpleJsonSerializer.DEFAULT.toString(DTOs.B.INSTANCE)).json().execute().assertBody(expected);
}
@Test

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

@Test
public void testParseParameterObjectMap() throws Exception {
  String in = "(name='foo bar')";
  ObjectMap r =  UonParser.DEFAULT.createSession().parse(null, in, BeanContext.DEFAULT.createSession().getClassMeta(ObjectMap.class));
  assertEquals("{name:'foo bar'}", SimpleJsonSerializer.DEFAULT.toString(r));
}

相关文章