2016-05-31 96 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)