title: Creating JSON format data through data frames in R
body: <p>I want to create a JSON data of the form </p>
  
  <pre><code>{"Recipe Name": "ABC",
  "Main Ingredient": "xyz",
  "Ingredients": {type:"a"
                   id:"1"},
                 {type:"b"
                   id:"2"},
                  {type:"b"
                   id:"3"}
  "Servings": 3,}
  </code></pre>
  
  <p>I have a data frame of type:</p>
  
  <pre><code>Recipe, Recipe Id ,Ingredients,Ingredients ID,Servings ,Main Ingredient,Main Ingredient ID  
   "abc"  , 2     ,    {"a","b","c"}  , {1,2,3,}   , 5   , "f"   ,7   
    "bcf"  , 3   ,       {"d","e","f"} , {4,5,7}  ,  4    ,"g"   ,8
     ....
  </code></pre>
  
  <p>I have tried usign rjson package but got character(0) as output .Can anyone help me with this please ? </p>
  
  <p>I did find one method though </p>
  
  <pre><code>&gt;library(RJSONIO)
  &gt;toJSON(dataframe)
  </code></pre>
  
  <p>Here is the output:</p>
  
  <blockquote>
    <p>[1] "{\n \"factor1\": [ \"115g\", \"1\", null, null ],\n\"unit1\": [ \"tub\", \"cups\", \"Greek\", \"baby\" ],\n\"item1\": [ \"tomatoes NA\", \"kalamata olives\", \"feta cheese\", \"rocket NA\" ] \n}"</p>
  </blockquote>
  
  <p>Which is not in the required format</p>