第 13 章 Miscellaneous

简介:

13.1. Object to Json

		
ObjectMapper mapper = new ObjectMapper();
User user = new User();

//Object to JSON in file
mapper.writeValue(new File("c:\\user.json"), user);

//Object to JSON in String
String jsonInString = mapper.writeValueAsString(user);

//Convert object to JSON string and pretty print
String jsonInString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(user);
		
		




原文出处:Netkiller 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。

目录
相关文章
|
算法 生物认证 开发工具
Guideline 5.1.2 - Legal - Privacy - Data Use and Sharing
你的应用程序收集的设备信息可能包括以下一些:attributesOfItemAtPath:error:, NSLocaleCountryCode, NSFileSystemSize, NSHomeDirectory,和serviceSubscriberCellularProviders。
234 0
|
Java API
解决办法:access restriction is not accessible due to restriction
解决办法:access restriction is not accessible due to restriction
100 0
why SpringComponentScanServer is needed
why SpringComponentScanServer is needed
71 0
why SpringComponentScanServer is needed
strange behavior:why u31000 is accessed for Extension project
Created by Wang, Jerry, last modified on May 20, 2015
92 0
strange behavior:why u31000 is accessed for Extension project
|
关系型数据库 MySQL
|
关系型数据库 MySQL
|
PHP 开发工具 git
|
JSON 数据格式