Пример #1
0
 public static JsonSchema getJsonSchema(Class<?> cls) {
   JsonSchema jsonSchema = null;
   try {
     jsonSchema = mapper.generateJsonSchema(cls);
   } catch (JsonMappingException e) {
   }
   return jsonSchema;
 }
Пример #2
0
  public static void main(String[] args) throws IOException {

    ObjectMapper mapper = new ObjectMapper();
    mapper.generateJsonSchema(UserAction.class);
    UserAction act = new UserAction();
    act.setAction(ActionTypeEnum.CONNECT.id);
    ConnectAction ca = new ConnectAction();
    act.setName("ul");
    act.setConnectAction(ca);
    System.out.println(mapper.writeValueAsString(act));
  }
Пример #3
0
 @Test
 public void SerializationTest() throws InterruptedException, IOException {
   Card half =
       new Card(
           3l,
           "Ползун",
           "Ползун, нападает через баррикады",
           1,
           10,
           0,
           1,
           CardTypeEnum.creature.getId(),
           3,
           0,
           0,
           1);
   // half.setImg(new byte[]{1,2,4,5,6,7,8});
   ObjectMapper requestMapper = new ObjectMapper();
   requestMapper.generateJsonSchema(Card.class);
   String s = requestMapper.writeValueAsString(half);
   System.out.println(s);
 }