场景:
调用外部接口取数据时,poatman可以正常使用,本地调用乱码;
数据量不是很大;
解决:
用postman调用外部接口取出数据存在本工程json文件下,代码取数据的时候直接从本地取:
文件目录格式:
其中test.json存放数据;
JSONReadTest.java中实现逻辑操作:
代码实现:
package com.example.selectBin;
import com.alibaba.fastjson.JSONObject;
import com.example.SelectBinApplication;
import com.google.common.base.Charsets;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframe