title: Processing JSON using rjson
body: <p>I'm trying to process some data in JSON format. <code>rjson::fromJSON</code> imports the data successfully and places it into a quite unwieldy list.</p>
  
  <pre><code>library(rjson)
  y &lt;- fromJSON(file="http://api.lmiforall.org.uk/api/v1/wf/predict/breakdown/region?soc=6145&amp;minYear=2014&amp;maxYear=2020")
  str(y)
  List of 3
   $ soc                : num 6145
   $ breakdown          : chr "region"
   $ predictedEmployment:List of 7
    ..$ :List of 2
    .. ..$ year     : num 2014
    .. ..$ breakdown:List of 12
    .. .. ..$ :List of 3
    .. .. .. ..$ code      : num 1
    .. .. .. ..$ name      : chr "London"
    .. .. .. ..$ employment: num 74910
    .. .. ..$ :List of 3
    .. .. .. ..$ code      : num 7
    .. .. .. ..$ name      : chr "Yorkshire and the Humber"
    .. .. .. ..$ employment: num 61132
    ...
  </code></pre>
  
  <p>However, as this is essentially tabular data, I would like it in a succinct <code>data.frame</code>. After much trial and error I have the result:</p>
  
  <pre><code>y.p &lt;- do.call(rbind,lapply(y[[3]], function(p) cbind(p$year,do.call(rbind,lapply(p$breakdown, function(q) data.frame(q$name,q$employment,stringsAsFactors=F))))))
  head(y.p)
    p$year                   q.name q.employment
  1   2014                   London     74909.59
  2   2014 Yorkshire and the Humber     61131.62
  3   2014     South West (England)     65833.57
  4   2014                    Wales     33002.64
  5   2014  West Midlands (England)     68695.34
  6   2014     South East (England)     98407.36
  </code></pre>
  
  <p>But the command seems overly fiddly and complex. Is there a simpler way of doing this?</p>