使用python将属性文件转换为JSON格式的文件

时间:2016-11-29 15:28:38

标签: python python-3.x

例如:

activ.contributionGateway.serviceId=Service.ContributionGateway
activ.contributionGateway.url= google.com
activ.contributionGateway.connectionRetry.interval=5
activ.contributionGateway.connectionRetry.timeout=60
activ.contributionGateawy.FDG.PermissionId=6710
activ.contentGateway.serviceId=Service.ContentGateway
activ.contentGateway.url=google.com
activ.contentGateway.connectionRetry.interval=5
activ.contentGateway.connectionRetry.timeout=60

输出应该是这样的:

 {  
           "Activ":{  
              "contributiongateway":{  
                 "serviceId":"Service.ContributionGateway",
                 "url":"google.com",
                 "connectionRetry":{  
                    "interval":5,
                    "timeout":60,

                 }         "FDG":{  
                    "PermissionId":6710,

                 }
              }      "contentGateway":{  
                 "serviceId":"Service.ContentGateway",
                 "url":"google.com",
                 "connectionRetry":{  
                    "interval":5,
                    "timeout":60
                 }
              }
           }
        }

如何使用python来处理所有花括号以及所有子元素和新元素

0 个答案:

没有答案