您的位置:首页 > 移动开发

json-mapper转换java对象到json字符串

2014-09-16 14:59 232 查看
ObjectMapper om = new ObjectMapper();
		String result;
		try {
			result = om.writeValueAsString(cookBookDetail);
			System.out.println(result);
		} catch (JsonGenerationException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		} catch (JsonMappingException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		} catch (IOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}

转到其它类型也是可以的,敲入writevalue就能看到。

spring-android引入了这个库,使用起来非常方便,避免再引入gson库了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: