package test;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.Test;
import com.alibaba.fastjson.JSON;
import model.BussinessVolume;
import model.MonthNumber;
import model.Sale;
class Month{
private String[] month;
public String[] getMonth() {
return month;
}
public void setMonth(String[] month) {
this.month = month;
}
}
class Month1{
private List<String> month;
public List<String> getMonth() {
return month;
}
public void setMonth(List<String> month) {
this.month = month;
}
}
public class FastJsonTest {
@Test
public void test() {
System.out.println("FastJsonTest.test()");
String[] months = {"1","2","3","4","5","6"};
Month month = new Month();
month.setMonth(months);
String json = JSON.toJSONString(month);
System.out.println(json);
}
@Test
public void test1() {
System.out.println("FastJsonTest.test1()");
String[] months = {"1","2","3","4","5","6"};
List<String> monthList = Arrays.asList(months);
Month1 month = new Month1();
month.setMonth(monthList);
String json = JSON.toJSONString(month);
System.out.println(json);
}
@Test
public void test2Map() {
System.out.println("FastJsonTest.test2Map()");
Map<String, List<String>> map = new HashMap<>();
String[] months = {"1","2","3","4","5","6"};
String[] monthName = {"Jan","Feb","Apr","Mar","May","June"};
List<String> monthList = Arrays.asList(months);
List<String> monthNameList = Arrays.asList(monthName);
map.put("month", monthList);
map.put("monthName", monthNameList);
String json = JSON.toJSONString(map);
System.out.println(json);
}
@Test
public void testComplextMap(){
/*销量*/
Integer[] salesVolume = {10,100,20,56,35,80};
/*营业额*/
double[] bussinessVolume = {10*10,100*8.5,20*9.5,56*9,35*9.5,80*9};
/*横轴, 月份数据*/
String[] months = {"1","2","3","4","5","6"};
Map<String, Object> map = new HashMap<>();
map.put("salesVolume", salesVolume);
map.put("bussinessVolume",bussinessVolume);
map.put("months", months);
System.out.println(JSON.toJSONString(map));
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
echarts.zip (34个子文件)
echarts
WebContent
META-INF
MANIFEST.MF 39B
WEB-INF
web.xml 1KB
lib
fastjson-1.2.31.jar 452KB
js
echarts3
echarts.common.min.js 369KB
jquery-3.2.1.js 262KB
index.jsp 716B
echarts3.jsp 2KB
.settings
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.wst.common.project.facet.core.xml 345B
org.eclipse.wst.common.component 473B
org.eclipse.wst.jsdt.ui.superType.container 49B
.jsdtscope 567B
org.eclipse.jdt.core.prefs 364B
src
model
Sale.java 236B
MonthNumber.java 197B
BussinessVolume.java 277B
test
FastJsonTest.java 2KB
servlet
GetSalesVolumeServlet.java 978B
GetMonthServlet.java 898B
GetAllDataServlet.java 1KB
GetBusinessVolume.java 1022B
.project 907B
.classpath 920B
.gitignore 8B
build
classes
model
MonthNumber.class 526B
BussinessVolume.class 517B
Sale.class 700B
test
Month.class 513B
Month1.class 707B
FastJsonTest.class 3KB
servlet
GetSalesVolumeServlet.class 2KB
GetMonthServlet.class 1KB
GetAllDataServlet.class 2KB
GetBusinessVolume.class 2KB
共 34 条
- 1
资源评论
- 嘻嘻~~2019-10-17代码里面没有完全没有注解,有些类看不懂干什么用的。并没有和数据库有连接。我是没有套用起来。看见前面有人说好,我就跟风一下吧。
- qq_338099192018-07-25挺不错的哦
- sfgis2018-01-17好东西 谢谢分享
- IvenShare2017-12-15很不错的资源,很好的解决了我的问题
- xds@松哥2017-11-25项目导进去运行获取不了后台数据怎么回事zhrubin2018-03-18后台跑起来了吗?
zhrubin
- 粉丝: 17
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功