2016-05-31 56 views
-1

如何获得display from below string?如何解析这个特定的json字符串?

[ 
    { 
     "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 
      } 
     ] 
     ] 
    } 
] 
+3

什么编程语言?你期望什么样的数据结构?你试过什么了? – Ruud

+0

我正在试图在JavaScript中。 – user3781360

+0

那么,由于没有名为'values'的字段,您将无法得到它。对于'陈列'你需要剥洋葱。最外层是一个数组,然后你有一个对象,另外两个数组,以及另一个要剥离的对象。 –

回答

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)