title: How to dynamically create a JSON object in c# (from an ASP.NET resource file)?
body: <p>I need to serialize the strings from a resource file (.resx) into a JSON object.  The resource file's keys are in flux and thus I cannot just create a C# object that accepts the appropriate values.  It needs to be a dynamic solution.  I am able to loop through the key-value pairs for the file, but I need an easy way to serialize them to JSON.</p>
  
  <p>I know I could do:</p>
  
  <pre><code>Object thing = new {stringOne = StringResource.stringOne; ...}
  </code></pre>
  
  <p>But, I'd rather have something like:</p>
  
  <pre><code>Object generic = {}
  foreach (DictionaryEntry entry in StringResource) {
      generic.(entry.Key) = entry.Value
  }
  </code></pre>
  
  <p>Or should I just create a custom JSON serializer that constructs the object piecemeal (i.e. foreach loop that appends part of the JSON string with each cycle)?</p>
  
  <p><strong>EDIT</strong><br>
  I ended up writing a quick JSON serializer that constructs the string one field at a time.  I didn't want to include a whole JSON library as this is the only use of JSON objects (for now at least).  Ultimately, what I wanted is probably impractical and doesn't exist as it's function is better served by other data structures.  Thanks for all the answers though!</p>