如何把对象转化为json数据?
json
适用于现代 C++ 的 JSON。
项目地址:https://gitcode.com/gh_mirrors/js/json
免费下载资源
·
第一步:
下载json所依赖的基本包。我已经上传到的csdn资源下载中。
第二步:核心代码
ObjectMapper objectMapper = new ObjectMapper();
String s = objectMapper.writeValueAsString(map); //这里的map是你从后台接收不同的数据类型的集合
这三行代码,可以(user对象类型,List<user>对象类型,map<String,User>对象类型,map<String,List<User>对象类型)的数据,都可以转化为json类型的数据。(json类型的数据类型:https://blog.csdn.net/longyanchen/article/details/93383099,我在上一篇博客上具有详细的介绍)。
GitHub 加速计划 / js / json
18
5
下载
适用于现代 C++ 的 JSON。
最近提交(Master分支:3 个月前 )
0f9e6ae0
Signed-off-by: Niels Lohmann <mail@nlohmann.me> 16 小时前
8a882f32
* Support any basic_json type in NLOHMANN_DEFINE_TYPE_* macros
Signed-off-by: kimci86 <kimci86@hotmail.fr>
* Test NLOHMANN_DEFINE_TYPE_* macros also support unordered_json
Signed-off-by: kimci86 <kimci86@hotmail.fr>
* Simplify test about NLOHMANN_DEFINE_TYPE_ with many arguments
Signed-off-by: kimci86 <kimci86@hotmail.fr>
* Remove extra scope in macros tests
Signed-off-by: kimci86 <kimci86@hotmail.fr>
* Remove unused test class in macros tests
Signed-off-by: kimci86 <kimci86@hotmail.fr>
* Update documentation about NLOHMANN_DEFINE_TYPE_* macros
Signed-off-by: kimci86 <kimci86@hotmail.fr>
* Fix NLOHMANN_JSON_SERIALIZE_ENUM documentation
Signed-off-by: kimci86 <kimci86@hotmail.fr>
* Mark some variables const in macros tests, fixes clang-tidy
Signed-off-by: kimci86 <kimci86@hotmail.fr>
* Workaround clang 3.5 issue with const object initialization
Signed-off-by: kimci86 <kimci86@hotmail.fr>
* Update highlighted lines in NLOHMANN_DEFINE_TYPE_* macros examples
Signed-off-by: kimci86 <kimci86@hotmail.fr>
* Fix swapped macros in documentation
Signed-off-by: kimci86 <kimci86@hotmail.fr>
* Remove extra backslashes at the end of macros
Signed-off-by: kimci86 <kimci86@hotmail.fr>
* Require basic_json type in NLOHMANN_DEFINE_TYPE_* generated functions
Signed-off-by: kimci86 <kimci86@hotmail.fr>
* Fix typos in macros documentation
Signed-off-by: kimci86 <kimci86@hotmail.fr>
---------
Signed-off-by: kimci86 <kimci86@hotmail.fr> 16 小时前
更多推荐
已为社区贡献5条内容
所有评论(0)