卜若的代码笔记系列-Web系列-SpringBoot-第二十五章:json的安装与使用,sqlserver数据库读取数据转对象

1.pom添加:

        <dependency>
			<groupId>com.alibaba</groupId>
			<artifactId>fastjson</artifactId>
			<version>1.2.39</version>
		</dependency>

2.使用:

转对象案例:

	public UserInfo getUserInfo(String userAcc)
		{
			
			Map<String, Object> imgMap = jdbcTemplate.queryForMap("select * from user_info where user_acc =?",userAcc);	
			UserInfo info =	JSON.parseObject(JSON.toJSONString(imgMap),UserInfo.class);
			return info;
	
		}

猜你喜欢

转载自blog.csdn.net/qq_37080133/article/details/84779413