title: JSON inside XML
body: <p>I want to know about standard and best practice in :</p>
  
  <p><strong>Case Scenario :</strong></p>
  
  <p>If a <strong>xml standard</strong> exist by <strong>"XYZ SPECIFICATION" <em>(ex : BPMN Specification)</em></strong> like :</p>
  
  <pre><code>&lt;home&gt;
  &lt;person name="ZEN" /&gt;
  &lt;person name="PAUL" /&gt;
  &lt;animal name="DOG" /&gt;
  &lt;animal name="CAT" /&gt;
  &lt;/home&gt;
  </code></pre>
  
  <p>and  "XYZ SPECIFICATION" also provide <strong>extension element</strong> to define your own tag like :</p>
  
  <pre><code>   &lt;home&gt;
      &lt;person name="ZEN" /&gt;
      &lt;person name="PAUL" /&gt;
      &lt;animal name="DOG" /&gt;
      &lt;animal name="CAT" /&gt;
      &lt;extension&gt;
      &lt;instrument-list&gt;
      &lt;type name="acoustic"&gt;
        &lt;instrument name="GUITAR" /&gt;
        &lt;instrument name="VIOLIN"  /&gt;
      &lt;/type&gt;
      &lt;type name="electronic"&gt;
        &lt;instrument name="GUITAR" /&gt;
        &lt;instrument name="VIOLIN"/&gt;
      &lt;/type&gt;
      &lt;/instrument-list&gt;
      &lt;/extension&gt;
      &lt;/home&gt;
  </code></pre>
  
  <p>Tag defined by standard are used by other client parser , they don't need to parse extension tag so i was thinking that it would be better to compress extension element using json (because json takes less space in compare to xml) :</p>
  
  <pre><code>  &lt;home&gt;
      &lt;person name="ZEN" /&gt;
      &lt;person name="PAUL" /&gt;
      &lt;animal name="DOG" /&gt;
      &lt;animal name="CAT" /&gt;
      &lt;extension&gt;
      &lt;instrument-list&gt;{"type":[{"name":"acoustic","instrument":[{"name":"GUITAR"},{"name":"VIOLIN"}]},{"name":"electronic","instrument":[{"name":"GUITAR"},{"name":"VIOLIN"}]}]}&lt;/instrument-list&gt;
      &lt;/extension&gt;
      &lt;/home&gt;
  </code></pre>
  
  <p>or </p>
  
  <pre><code>&lt;home&gt;
      &lt;person name="ZEN" /&gt;
      &lt;person name="PAUL" /&gt;
      &lt;animal name="DOG" /&gt;
      &lt;animal name="CAT" /&gt;
      &lt;extension&gt;
      &lt;instrument-list&gt;&lt;![CDATA[ {"type":[{"name":"acoustic","instrument":[{"name":"GUITAR"},{"name":"VIOLIN"}]},{"name":"electronic","instrument":[{"name":"GUITAR"},{"name":"VIOLIN"}]}]} ]]&gt;&lt;/instrument-list&gt;
      &lt;/extension&gt;
      &lt;/home&gt;
  </code></pre>
  
  <p>Is it violates standard and best practices ?</p>