title: JSON pattern recognition
body: <p>Suppose I have a JSON request body <code>req1</code>, and it resulted in a JSON response <code>resp1</code>, some of whose key-values are identical to those in <code>req1</code>. Now suppose I have another JSON request <code>req2</code>, and I want to construct a JSON response <code>resp2</code> which is a duplicate of <code>resp1</code>, but in which the common keys have their values replaced by the values from <code>req2</code>.</p>
  
  <p>What strategy might be used to tackle this?</p>
  
  <p>As a concrete example, suppose <code>req1</code> is this:</p>
  
  <pre><code>{"Name":"Alan"}
  </code></pre>
  
  <p>And suppose this is <code>resp1</code>:</p>
  
  <pre><code>{"output":{"Name":"Alan", "Cat": "12"}}
  </code></pre>
  
  <p>Note that <code>"Name":"Alan"</code> appears in both.</p>
  
  <p>If <code>req2</code> is this:</p>
  
  <pre><code>{"Name":"Bancorp"}
  </code></pre>
  
  <p>Then I'd like to create <code>resp2</code> from <code>resp1</code> like this:</p>
  
  <pre><code>{"output":{"Name":"Bancorp", "Cat": "12"}}
  </code></pre>
  
  <p>Crucially, the document structure of <code>req*</code> and <code>resp*</code> <em>are not known in advance</em>, and the only knowledge is that the structure of <code>req1</code> and <code>req2</code> are similar, and likewise for <code>resp1</code> and <code>resp2</code>. </p>
  
  <p>In other words, I'm looking for a flexible pattern-recognition that will "learn" from an initial <code>req1</code>/<code>resp1</code> pair by identifying fields that occurred in both, and then be able to respond to future <code>req*</code> inputs by making the proper substitutions to a copy of <code>resp1</code>.</p>
  
  <p>Is this something which already exists? If not, how might it be implemented in <code>JSON.Net</code>?</p>