title: json-schema: how to transform from one json-schema to another
body: <p>I have the two different <a href="http://json-schema.org/" rel="noreferrer">json-schemas</a>:</p>
  
  <blockquote>
    <p>schemaA -> A calendar as defined at <a href="http://json-schema.org/calendar" rel="noreferrer">http://json-schema.org/calendar</a></p>
  </blockquote>
  
  <pre><code>{
      "$schema": "http://json-schema.org/draft-04/schema#",
      "description": "A representation of an event",
      "type": "object",
      "required": [ "dtstart", "summary" ],
      "properties": {
          "dtstart": {
              "format": "date-time",
              "type": "string",
              "description": "Event starting time"
          },
          "dtend": {
              "format": "date-time",
              "type": "string",
              "description": "Event ending time"
          },
          "summary": { "type": "string" },
          "location": { "type": "string" },
          "url": { "type": "string", "format": "uri" },
          "duration": {
              "format": "time",
              "type": "string",
              "description": "Event duration"
          },
          "rdate": {
              "format": "date-time",
              "type": "string",
              "description": "Recurrence date"
          },
          "rrule": {
              "type": "string",
              "description": "Recurrence rule"
          },
          "category": { "type": "string" },
          "description": { "type": "string" },
          "geo": { "$ref": "http: //json-schema.org/geo" }
      }
  }
  </code></pre>
  
  <blockquote>
    <p>schemaB -> Another calendar schema (also json-schema version draft-04)</p>
  </blockquote>
  
  <p>My quesiton is simple. I have a javascript object 'calendarA' that follows the first schema, i.e.,</p>
  
  <pre><code>validates(calendarA, schemaA); // true
  </code></pre>
  
  <p>I want to describe a transformation between the schemas, i.e., from schemaA to schemaB, so I can pass calendarA as input and get a new calendarB that fits schemaB. Put it in code:</p>
  
  <pre><code>var calendarB = fromSchemaAtoB(calendarA, schemaA, schemaB);
  validates(calendarB, schemaB); // true
  </code></pre>
  
  <p>From your point of view which is the best approach/tools to write fromSchemaAtoB guys? I really want to describe transfomations using the schemas, something like:</p>
  
  <pre><code>schemaB.properties.foo = schemaA.properties.dtstart
  </code></pre>
  
  <p>I saw a lot of basic json transformation packages but it seems to me that in most of them you specify your output as external templates that do not take into account the schemas (so result could be invalid with respect to schemaB).</p>
  
  <p>Thank you so much in advance!!</p>
  
  <p>JG</p>
  
  <p>PS: I prefer javascript based solutions if possible but I am really open to any possibility.</p>
  
  <p>EDIT 1: To clarify after reading @jason's answer, the question is how to better describe such relations between schemas and how to apply them to obtain calendarB. So if you prefer:</p>
  
  <pre><code>var calendarB = transform(calendarA, schemaA, schemaB, relationsAtoB);
  validates(calendarB, schemaB); // true
  </code></pre>
  
  <p>and the question then is how to better describe "relationsAtoB" and how to implement the "transform" function.</p>