如何解析这个特殊的json字符串?

时间:2016-05-31 21:17:37

标签: json parsing servicenow

如何从字符串下方获取显示

[  
   {  
      "hdr":"",
      "forElement":"",
      "preFields":[  

      ],
      "rows":[  
         [  
            {  
               "field":"subject_area",
               "label":"Subject Area",
               "mandatory":"",
               "type":"text",
               "giveFocus":"",
               "reference":"",
               "choiceOptions":null,
               "refQual":"",
               "onChangeFunc":"",
               "cellCSS":"",
               "labelCSS":"",
               "show":"always",
               "imageSrc":"",
               "value":"helo",
               "display":"helods",
               "relatedTable":"",
               "disabled":false
            },
            {  
               "field":"table",
               "label":"Table",
               "mandatory":"",
               "type":"text",
               "giveFocus":"",
               "reference":"",
               "choiceOptions":null,
               "refQual":"",
               "onChangeFunc":"",
               "cellCSS":"",
               "labelCSS":"",
               "show":"always",
               "imageSrc":"",
               "value":"helasdsao",
               "display":"helo",
               "relatedTable":"",
               "disabled":false
            },
            {  
               "field":"column",
               "label":"Column",
               "mandatory":"",
               "type":"text",
               "giveFocus":"",
               "reference":"",
               "choiceOptions":null,
               "refQual":"",
               "onChangeFunc":"",
               "cellCSS":"",
               "labelCSS":"",
               "show":"always",
               "imageSrc":"",
               "value":"hesadslo",
               "display":"helo",
               "relatedTable":"",
               "disabled":false
            },
            {  
               "field":"description",
               "label":"Description",
               "mandatory":"",
               "type":"text",
               "giveFocus":"",
               "reference":"",
               "choiceOptions":null,
               "refQual":"",
               "onChangeFunc":"",
               "cellCSS":"",
               "labelCSS":"",
               "show":"always",
               "imageSrc":"",
               "value":"helo",
               "display":"hedsadlo",
               "relatedTable":"",
               "disabled":false
            }
         ]
      ]
   }
]

1 个答案:

答案 0 :(得分:0)

使用python:

import json
y=json.loads('<put or read your json string>')
rows=y[0]['rows'][0]
for row in rows: 
  value=row['value']
  display=row['display']
  print(value+','+ display)
相关问题