作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是我需要传递给其他 API 的 JSON 请求,我的问题是我不知道如何创建一个可以包含其他对象的对象。
最好的方法是什么,我将使用 ObjectMapper 将对象转换为像这样的 json。
{
"request": {
"head": {
"version": "1.0.0",
"function": "sample.function",
"clientId": "clientId",
"clientSecret": "clientSecret",
"reqTime": "2001-07-04T12:08:56+05:30",
"reqMsgId": "reqMessageID",
"reserve": ""
},
"body": {
"occurTime": "2018-03-04T12:08:56+08:00",
"bizScene": "SAMPLE_BIZ",
"envInfo": {
"tokenId": "jkahsdhsjakdhkjsajdsahdkjsakdhsa===",
"clientIp": "127.0.0.1",
"appVersion": "v0.1.0",
"terminalType": "NOP"
},
"extendInfo": {
"PSID":"87943297427",
"PSID_CreatedDate":"2018-01-04T12:08:56+08:00",
"mobtelLinkingDate" : "2018-03-04T12:08:56+08:00",
"mobtelUnlinkingDate" : "2018-04-04T12:08:56+08:00",
"activeLinkedMobtel" : "123756"
},
"accountInfo": {
"userMobile": "123756"
},
"operationInfoDTO" : {
"operationOrigin": "TWEETER",
},
"operationType": "SAMPLE",
"operationResult": "FALSE",
}
},
"signature": "signature string"
}
最佳答案
我给使用的根对象起了一个名字this用于生成样板 bean 对象的网站
"rootObj":{
"request": {
"head": {
"version": "1.0.0",
"function": "sample.function",
"clientId": "clientId",
"clientSecret": "clientSecret",
"reqTime": "2001-07-04T12:08:56+05:30",
"reqMsgId": "reqMessageID",
"reserve": ""
},
"body": {
"occurTime": "2018-03-04T12:08:56+08:00",
"bizScene": "SAMPLE_BIZ",
"envInfo": {
"tokenId": "jkahsdhsjakdhkjsajdsahdkjsakdhsa===",
"clientIp": "127.0.0.1",
"appVersion": "v0.1.0",
"terminalType": "NOP"
},
"extendInfo": {
"PSID":"87943297427",
"PSID_CreatedDate":"2018-01-04T12:08:56+08:00",
"mobtelLinkingDate" : "2018-03-04T12:08:56+08:00",
"mobtelUnlinkingDate" : "2018-04-04T12:08:56+08:00",
"activeLinkedMobtel" : "123756"
},
"accountInfo": {
"userMobile": "123756"
},
"operationInfoDTO" : {
"operationOrigin": "TWEETER",
},
"operationType": "SAMPLE",
"operationResult": "FALSE",
}
},
"signature": "signature string"
}
关于java - 如何在java中创建一个可以像这样转换为json的对象类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59838269/
我是一名优秀的程序员,十分优秀!