title: Parsing input based on JSON schema
body: <p>We're building a frontend project for a web app that communicates with a backend written by another team. Some of the developers work on both projects, and have better understanding of changes to the backend and response fields coming back.</p>
  
  <p>Recently we had portions of frontend break as they made changes in parts of the app based on changes to the backend without updating the logic in all places. To mitigate this I want to put in place a concept of a mask/template that all response data would be curated through. That way the rest of the members on the team who're not as familiar with the backend can notice/address these bugs.</p>
  
  <p>To do so, I'm considering using JSON Schema. Instead of simply validating, however, I want to parse the backend data through it (removing the fields not present in the schema). This way the developer making changes in the frontend in response to a backend change would also need to update this template, therefore triggering a test failure until all logic using this schema is updated (not just the logic he touched). I'm playing with <a href="https://www.npmjs.com/package/jsonschema" rel="nofollow noreferrer">https://www.npmjs.com/package/jsonschema</a>, but it doesn't seem to have a way to remove excess fields, just test for them.</p>
  
  <p>Within JSON Schema, I can also set <code>additionalProperties</code> flag. However, it has 2 problems with it:</p>
  
  <ul>
  <li>It doesn't cause the validator to remove the fields, it simply dumps them to error array</li>
  <li>It needs to be set individually at each nested level, therefore I need to traverse the entire JSON structure, at which point I basically end up writing my own parser/validator.</li>
  </ul>
  
  <p>Perhaps validator is not the right tool for this, but that's all I'm finding when searching for JSON schema parsers. Can someone guide me in the right direction so that I don't reinvent the wheel? It sounds like this functionality is very similar to what a validator already does and I would rather do this processing in the same pass.</p>