title: C# JSON parse instead of R
body: <p>Suppose I have a nested json file which looks like this:</p>
  
  <blockquote>
    <p>[{"toplevel":{"firstleveldata":{"id":12345,"no":123}},"secondleveldata":{"fruit":{"apples":"y"},"veg":{"small":{"gree":{"fresh":{"available":3}}}}},"thirdleveldata":{"fruit":{"changes":[{"itemid":1,"subno":1,"green":[],"red":[{"extraid":2,"element":5}]}]}}}]</p>
  </blockquote>
  
  <p>and the following R code which can parse the it to a nice data.frame except for the last one (if that can be fixed to that's a bonus)</p>
  
  <p>what would be neat altenative using C# look like? It's not something i've ever coded in before so wouldn't know where to start.  </p>
  
  <p>The end goal being to export the nested JSON into a csv, multiple csvs with primary / foreign keys to merge on of necessary.</p>
  
  <p>R code for context.</p>
  
  <pre><code>library(jsonlite)
  
  library(tidyverse)
  
  fun &lt;- function(x)
         {list(
  #keys
  id = pluck(x,"toplevel","firstleveldata","id", .default = NA),
  no = pluck(x,"toplevel","firstleveldata","no", .default = NA),
  
  apples = pluck(x,"secondleveldata","fruit","apples", .default = NA),
  itemid = pluck(x,"toplevel","thirdleveldata","fruit","changes","itemid", .default = NA) #doesn't work)}
  
  out&lt;-map_df(list.files("my_json_file",full.names=TRUE),~map_df(fromJSON(txt=., simplifyVector=FALSE), fun))
  
  out
  </code></pre>
  
  <p>Thanks</p>