title: Extracting data from an unusual JSON
body: <p>Is there a way to make a nice CSV out of the following JSON code?</p>
  
  <pre><code>{
      "cod:e1!!@23" : {
          "typeA" : {
              "lsk:d##fjd": {
                  "title" : "slkdfjlkdjfd",
                  "year" : "2014"
              },
          "sdfdsfsd" : {
              "title" : "slkdfjlkdjfddewfsdfd",
              "year" : "2015"
              }
          },
          "Ct@ype" : {
              "sd$!!fs:$dfds" : {
                  "title" : "slkdfjsdfsdfdsfsd",
                  "year" : "2012"
              }
          }
      }
  }
  </code></pre>
  
  <p>Here's what I tried in jq:</p>
  
  <pre><code>jq -rc 'keys[] as $x 
    | .[]|keys[] as $y
    | .[]|keys[] as $z
    |.[]
    |[$x,$y,$z,.year] | @csv'
  
  jq -rc 'keys_unsorted[] as $x
    | .[]|keys_unsorted[] as $y
    | .[]|keys_unsorted[] as $z
    | .[]|[$x,$y,$z,.year] | @csv'
  </code></pre>
  
  <p>But the output is not correct, because if there are several such records then  the keys come out as sorted and permuted. I also tried keys_unsorted, but it didn't resolve the issue.</p>
  
  <p>Fixing the original JSON generation is not an option at this point in time, so any help will be appreciated.</p>
  
  <p>Ideally, I would get:</p>
  
  <pre><code>"cod:e1!!@23","typeA","lsk:d##fjd","slkdfjlkdjfd","2014"
  "cod:e1!!@23","typeA","sdfdsfsd","slkdfjlkdjfddewfsdfd","2015"
  "cod:e1!!@23","Ct@ype","sd$!!fs:$dfds","slkdfjsdfsdfdsfsd","2012"
  </code></pre>