title: Variant datatype library for C
body: <p>Is there a decent open-source C library for storing and manipulating<br>
  dynamically-typed variables (a.k.a. variants)?  I'm primarily interested in atomic values (int8, int16, int32, uint, strings, blobs, etc.), while JSON-style arrays and objects as well as custom objects would also be nice.  A major case where such a library would be useful is in working with SQL databases.</p>
  
  <p>The most obvious feature of such a library would be a single type for all supported values, e.g.:</p>
  
  <pre><code>struct Variant {
      enum Type type;
      union {
          int8_t int8_;
          int16_t int16_;
          // ...
      };
  };
  </code></pre>
  
  <p>Other features might include converting Variant objects to/from C structures (using a binding table), converting values to/from strings, and integration with an existing database library such as SQLite.</p>
  
  <p>Note:  I do not believe this is question is a duplicate of <a href="https://stackoverflow.com/questions/649649/any-library-for-generic-datatypes-in-c">Any library for generic datatypes in C?</a> , which refers to "queues, trees, maps, lists".  What I'm talking about focuses more on making working with SQL databases roughly as smooth as working with them in interpreted languages.</p>