title: JSON Arrays and Javascript
body: <p>im new to json.  Ive created objects similar in structure to the attached json string.  I believe what ive created, intentionally, is a nested array object...</p>
  
  <pre><code>  {
     "tracelog":{
        "title":"",
        "phase":"12",
        "users":"",
        "logduration":"",
        "logdurationtype":"undefined",
        "showlogduedate":"no",
        "durationstartfield":"",
        "fields":[
           {
              "atts":[
                 {
                    "name":"dfvdfv",
                    "fieldtype":"text",
                    "followedbydate":"no",
                    "datetype":"---",
                    "fieldduration":"---",
                    "fielddurationtype":"undefined",
                    "fielddurationstart":"",
                    "autocalcunits":"none",
                    "validationtype":"none",
                    "fieldvisibleto":"",
                    "fieldaccessibleto":"",
                    "dropdown":""
                 }
              ]
           },
           {
              "atts":[
                 {
                    "name":"ffff",
                    "fieldtype":"text",
                    "followedbydate":"no",
                    "datetype":"---",
                    "fieldduration":"---",
                    "fielddurationtype":"undefined",
                    "fielddurationstart":"",
                    "autocalcunits":"none",
                    "validationtype":"none",
                    "fieldvisibleto":"",
                    "fieldaccessibleto":"",
                    "dropdown":""
                 }
              ]
           }
        ]
     }
  }
  </code></pre>
  
  <p>What i want to do is find the length of the array named "atts".  Ive parsed the JSON string as follows...</p>
  
  <pre><code>var obj = jQuery.parseJSON(jsonstring);
  </code></pre>
  
  <p>... and later call the objects thusly ...</p>
  
  <pre><code>obj.tracelog.fields.length
  </code></pre>
  
  <p>accurately tells me how many fields there are.</p>
  
  <pre><code>obj.tracelog.fields[0].atts.name
  </code></pre>
  
  <p>... gives me the name, but throws a console error saying field[0] is undefined. so it works, and it doesnt. while ....</p>
  
  <pre><code>obj.tracelog.fields[0].atts.length
  </code></pre>
  
  <p>does NOT give me the number of fields in the "atts" array (if it is infact an array - id like it to be) but gives me "undefined".</p>
  
  <p>Can someone point out where im going wrong here?</p>
  
  <p>thanks.</p>