Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Assuming your JSON string is in a variable <code>$json</code>, it goes like this:</p> <pre><code>var employees_list = JSON.parse($json); </code></pre> <p>Then you can access the information via:</p> <pre><code>employees_list[0].employees.education // gives you "BE\/B.Tech" // and employees_list[0]["0"].count // gives you 1. </code></pre> <p>You can also loop over the array and access all the different <code>education</code> this way.</p> <p><strong>Update:</strong></p> <p>To better demonstrate which expression accesses which information:</p> <pre><code>[ // employees_list { // employees_list[0] "employees": { // employees_list[0].employees "education": "BE\/B.Tech" // employees_list[0].employees.education }, "0": { // employees_list[0]["0"] "count": "1" // employees_list[0]["0"].count } }, { // employees_list[1] "employees": { // employees_list[1].employees "education": "MBA" // employees_list[1].employees.education }, "0": { // employees_list[1]["0"] "count": "3" // employees_list[1]["0"].count } } ] </code></pre> <p>Generally <code>employees_list[0].employees</code> is the same as <code>employees_list[0]["employees"]</code> but this does not work for numbers, because properties and variables are not allowed to start with numbers. So you can <strong>only</strong> use <code>employees_list[0].["0"]</code> <strong>and not</strong> <code>employees_list[0].0</code>.</p> <hr> <p>The structure of your JSON string looks a bit strange though. You should consider to structure it differently if you can.</p> <p>For example:</p> <pre><code>[ { "education": "BE\/B.Tech", "count": "1" }, { "education": "MBA" "count": "3" } ] </code></pre> <p>The <code>"0"</code> key in your original JSON string seems to serve no purpose and just complicates the access.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload