python - 在 Python 中提取所有父/子 Json 值
问题描述
下面是输入的 Json 模式和预期的输出响应 \n
输入模式:{“request”:{“requestId”:“ABCDE”,“modelType”:“NEW”,“lineOfBusiness”:“WC”,“requestDate”:“2019-12-10”,“evaluationDate”:“ 2019-12-11”、“jobNumber”:“GDERS”、“branchNumber”:“IODGH”、“quoteEffectiveDate”:“2019-12-11”、“policyNumber”:“12XYZ34”、“policyEffectiveDate”:“2019- 12-10”,“policyExpirationDate”:“2020-12-09”},“premiumHistory”:[{“jobNumber”:“GDERS”,“branchNumber”:“IODGH”、“policyNumber”:“”、“policyEffectiveDate”:“2019-04-01”、“policyExpirationDate”:“2020-03-31”、“classCode”:[{“classCode”:“AB”、“ transactionDate”:“2019-04-01”,“transactionType”:“1”,“locationNumber”:“12345”,“premium”:1200,“payrollOrExposure”:100 },“2020-03-31”,“classCode”:[{“classCode”:“AB”,“transactionDate”:“2019-04-01”,“transactionType”:“1”,“locationNumber”:“12345”, “溢价”:1200,“payrollOrExposure”:100 },“2020-03-31”,“classCode”:[{“classCode”:“AB”,“transactionDate”:“2019-04-01”,“transactionType”:“1”,“locationNumber”:“12345”, “溢价”:1200,“payrollOrExposure”:100 },“溢价”:1200,“payrollOrExposure”:100 },“溢价”:1200,“payrollOrExposure”:100 },
{
"classCode":"CD",
"transactionDate": "2019-04-01",
"transactionType": "1",
"locationNumber": "12345",
"premium": 1200,
"payrollOrExposure": 100
}
]
},
]
}
Output Expected:
request.requestId = "ABCDE"
request.modelType = "NEW"
..
..
..
..
premiumHistory.jobNumber="GDERS"
premiumHistory.branchNumber="IODGH"
premiumHistory.policyNumber=""
..
premiumHistory.classCode.classCode="AB"
premimumHistory.classCode.transactionDate="2019-04-01"
..
..
..
代码需要在 python 中,我已经使用不同的技术进行了测试,但无法获得所需的输出。非常感谢任何帮助。
问候,
解决方案
对于格式问题,我深表歉意。甚至没有意识到这一点。
下面是输入的 Json 模式和预期的输出响应 \n
输入模式:
{
"request": {
"requestId": "ABCDE",
"modelType": "NEW",
"lineOfBusiness": "WC",
"requestDate": "2019-12-10",
"evaluationDate": "2019-12-11",
"jobNumber": "GDERS",
"branchNumber": "IODGH",
"quoteEffectiveDate": "2019-12-11",
"policyNumber": "12XYZ34",
"policyEffectiveDate": "2019-12-10",
"policyExpirationDate": "2020-12-09"
},
"premiumHistory": [{
"jobNumber": "GDERS",
"branchNumber": "IODGH",
"policyNumber": "",
"policyEffectiveDate": "2019-04-01",
"policyExpirationDate": "2020-03-31",
"classCode":
[
{
"classCode":"AB",
"transactionDate": "2019-04-01",
"transactionType": "1",
"locationNumber": "12345",
"premium": 1200,
"payrollOrExposure": 100
},
{
"classCode":"CD",
"transactionDate": "2019-04-01",
"transactionType": "1",
"locationNumber": "12345",
"premium": 1200,
"payrollOrExposure": 100
}
]
},
]
}
Output Expected:
request.requestId = "ABCDE"
request.modelType = "NEW"
..
..
..
..
premiumHistory.jobNumber="GDERS"
premiumHistory.branchNumber="IODGH"
premiumHistory.policyNumber=""
..
premiumHistory.classCode.classCode="AB"
premimumHistory.classCode.transactionDate="2019-04-01"
..
..
..
推荐阅读
- javascript - 创建 60k+ 页面会降低页面性能
- python-3.x - distutils.dir_util.copy_tree() 的调试和可能原因不存在或不是常规文件
- node.js - 运行命令 yarn start 时出现 Chrome 错误
- selenium - Selenium - 如何点击这个跨度?
- python - can i define k elem in random.sample function as an variable?
- javascript - 用户的Javascript动态插入表单行
- excel - 在 Excel 公式中使用 IF AND 语句不起作用
- reactjs - navigator.geolocation.getCurrentPosition 在本地工作,但在部署时不工作
- python - AttributeError:“numpy.ndarray”对象没有属性“_in_multi_worker_mode”
- azure-active-directory - 用于 AppRegistration 的 Exchange 365 中的 New-ApplicationAccessPolicy 无法限制访问