12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- package com.fjhx.customer.handle;
- import com.fjhx.customer.entity.xiaoman.po.XiaomanCustomer;
- import com.fasterxml.jackson.core.type.TypeReference;
- import com.fasterxml.jackson.databind.ObjectMapper;
- import com.fjhx.customer.entity.xiaoman.vo.CustomerApiVo;
- import com.fjhx.customer.entity.xiaoman.vo.CustomerListApiVo;
- import java.io.BufferedReader;
- import java.io.FileReader;
- import java.io.IOException;
- public class HandleXiaomanData {
- public static void main(String[] args) {
- String filePath = "D:\\java_conding\\erhong\\hx-customer\\src\\main\\java\\com\\fjhx\\customer\\handle\\aaa.json";
- String jsonData = "";
- try (BufferedReader br = new BufferedReader(new FileReader(filePath))) {
- String line;
- while ((line = br.readLine()) != null) {
- jsonData += line;
- }
- handleList(jsonData, new TypeReference<R<CustomerListApiVo>>() {});
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- public static <T> T handleList(String res, TypeReference<R<T>> typeReference) {
- ObjectMapper objectMapper = new ObjectMapper();
- try {
- R<T> result = objectMapper.readValue(res, typeReference);
- if (result.isOk()) {
- return result.getData();
- }
- return null;
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
- }
- }
|