title: Ruby, How to generate JSON format?
body: <p>I need to send an input in the below format to an API, I'm running into problems producing the desired format which is below.</p>
  
  <blockquote>
    <p>{ "application" :
    "{\"attributes\":{\"type\":\"genesis__Applications__c\"},\"genesis__Days_Convention__c\":\"ACTUAL/ACTUAL\",  \"RecordTypeID\":\"012260000004RHF\",<br>
    \"genesis__Interest_Calculation_Method__c\":\"Flat\",<br>
    \"genesis__Interest_Rate__c\":10.0000,<br>
    \"genesis__Loan_Amount__c\":22120.00,<br>
    \"Application_Completed__c\":false,<br>
    \"genesis__Payment_Frequency__c\":\"WEEKLY\",<br>
    \"genesis__Product_Type__c\":\"LOAN\",       \"genesis__Term__c\":24, 
    \"genesis__Interest_Only_Period__c\":2,<br>
    \"genesis__Balloon_Payment__c\":100.00}", "relatedObjects" :   "{<br>
    \"genesis__Account__c\" :       {\"attributes\":<br>
    {\"type\":\"Account\"},       \"Name\":\"LONDON METALS HOLDINGS
    LIMITED\" },     \"Loan_Product_Purpose__c\" :      {\"attributes\":<br>
    {\"type\":\"Loan_Product_Purpose__c\"},       \"Name\":\"Equipment
    Purchase\" }}" }</p>
  </blockquote>
  
  <p>API is accepting above format as input.</p>
  
  <p>Input specifications as shown.
  <a href="https://i.stack.imgur.com/Ak0EN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ak0EN.png" alt="enter image description here"></a></p>
  
  <p>We tried JSON builder that did not help instead producing the below format
  which is not valid for API.</p>
  
  <blockquote>
    <p>"\"{:attributes:{:type:\\"genesis__Applications__c\\"},
    :genesis__Days_Convention__c:\\"ACTUAL/ACTUAL\\",
    :RecordTypeID:\\"012260000004RHF\\",
    :genesis__Interest_Calculation_Method__c:\\"Flat\\",
    :genesis__Interest_Rate__c:10.0, :genesis__Loan_Amount__c:22120.0,
    :Application_Completed__c:false,
    :genesis__Payment_Frequency__c:\\"WEEKLY\\",
    :genesis__Product_Type__c:\\"LOAN\\", :genesis__Term__c:24,
    :genesis__Interest_Only_Period__c:2,
    :genesis__Balloon_Payment__c:100.0}\""</p>
  </blockquote>
  
  <p>edit1: Input Hash object</p>
  
  <blockquote>
    <p>{:application=>   {:attributes=>{:type=>"genesis__Applications__c"},<br>
    :genesis__Days_Convention__c=>"ACTUAL/ACTUAL",<br>
    :RecordTypeID=>"012260000004RHF",<br>
    :genesis__Interest_Calculation_Method__c=>"Flat",<br>
    :genesis__Interest_Rate__c=>10.0,<br>
    :genesis__Loan_Amount__c=>22120.0,<br>
    :Application_Completed__c=>false,<br>
    :genesis__Payment_Frequency__c=>"WEEKLY",<br>
    :genesis__Product_Type__c=>"LOAN",    :genesis__Term__c=>24,<br>
    :genesis__Interest_Only_Period__c=>2,<br>
    :genesis__Balloon_Payment__c=>100.0},  :relatedObjects=><br>
    {:genesis__Account__c=>{:attributes=>{:type=>"Account"},
    :Name=>"LONDON METALS HOLDINGS LIMITED"},<br>
    :Loan_Product_Purpose__c=>{:attributes=>{:type=>"Loan_Product_Purpose__c"}, :Name=>"Equipment Purchase"}}}</p>
  </blockquote>