从txt文件以特定格式创建json

时间:2018-09-24 16:35:00

标签: arrays json key-value

我有一个报告文本文件,该报告显示为

CURRENT BUILD is 220

TC-001
fail
[FileMgmt-2.1.7] User uploads file to the main folder

TC-002
fail
[FileMgmt-5.1.12] User deletes file from main folder


CURRENT BUILD is 221

TC-002
pass
[FileMgmt-5.1.12] User deletes file from main folder

TC-001
pass
[FileMgmt-2.1.7] User uploads file to the main folder

我需要从该txt文件创建一个json文件,例如主键将是测试用例ID:TC-001,然后一个值是测试用例名称:[FileMgmt-2.1.7]用户将文件上传到主文件夹,然后再次作为下一个值应该是键值对(220:通过; 221:失败)

类似:

{TC-001 : [FileMgmt-2.1.7] User uploads file to the main folder, {220:pass, 221: fail}},
{TC-002 : [FileMgmt-5.1.12] User deletes file from main folder, {220:pass, 221: fail}}

怎么可能。请帮助

0 个答案:

没有答案