-1

How to get values and display from below string?

[  
   {  
      "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
            }
         ]
      ]
   }
]
Kirk
  • 16,182
  • 20
  • 80
  • 112
  • 3
    What programming language are you using? What kind of data structure do you expect as a result? What have you tried so far? – Ruud May 31 '16 at 21:26
  • I am trying this in javascript. – user3781360 May 31 '16 at 21:30
  • Well, since there is no field named `values` you're going to have trouble getting it. For `display` you need to peel the onion. The outermost layer is an array, then you have an object, two more arrays, and another object to peel. – Hot Licks May 31 '16 at 22:44

1 Answers1

0

Using 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)
Vivek
  • 357
  • 1
  • 18