package cc.smtweb.framework.test;

import cc.smtweb.framework.core.util.JsonUtil;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import lombok.Data;
import org.junit.jupiter.api.Test;
import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;

import java.util.ArrayList;
import java.util.List;

public class JsonTest {
  @Test
  public void testList() throws JsonProcessingException {
    {
      List<Object> list = JsonUtil.OBJECT_MAPPER.readValue("[{ \"value\": 1 }, { \"value\": 2 }, { \"value\": 3 }]", ArrayList.class);

      System.out.println(list.get(0).getClass());
    }

    {
      List<JsonItem> list = JsonUtil.parseList("[{ \"value\": 1 }, { \"value\": 2 }, { \"value\": 3 }]", JsonItem.class);

      System.out.println(list.get(0).getClass());
    }
  }
}

@Data
class JsonItem {
  private Integer value;
}
