title: ServiceStack.Text.JsonObject.Parse vs. NewtonSoft.Json.Linq.JObject.Parse for nested tree of 'dynamic' instances?
body: <p>I'd like to try ServiceStack's json parsing, but I've already figured out how to do something I need via Newtonsoft. Can this same thing by done via ServiceStack?</p>
  
  <p>I've tried with the commented out code but it gives exceptions, see below for exception details.</p>
  
  <p>Thanks!</p>
  
  <p>Josh</p>
  
  <pre><code>    [Test]
      public void TranslateFromGitHubToCommitMessage()
      {
          const string json =
  @"
  {
  'commits': 
  [
      {
        'author': {
          'email': 'dev@null.org',
          'name': 'The Null Developer'
        },
        'message': 'okay i give in'
      },
      {
        'author': {
          'email': 'author@github.com',
          'name': 'Doc U. Mentation'
        },
        'message': 'Updating the docs, that\'s my job'
      },
      {
        'author': {
          'email': 'author@github.com',
          'name': 'Doc U. Mentation'
        },
        'message': 'Oops, typos'
      }
  ]
  }
  ";
          dynamic root = JObject.Parse(json);
          //dynamic root = ServiceStack.Text.JsonSerializer.DeserializeFromString&lt;JsonObject&gt;(json);
          //dynamic root = ServiceStack.Text.JsonObject.Parse(json);
  
          var summaries = new List&lt;string&gt;();
  
          foreach (var commit in root.commits)
          {
              var author = commit.author;
              var message = commit.message;
              summaries.Add(string.Format("{0} &lt;{1}&gt;: {2}", author.name, author.email, message));
          }            
  
          const string expected1 = "The Null Developer &lt;dev@null.org&gt;: okay i give in";
          const string expected2 = "Doc U. Mentation &lt;author@github.com&gt;: Updating the docs, that's my job";
          const string expected3 = "Doc U. Mentation &lt;author@github.com&gt;: Oops, typos";
  
          Assert.AreEqual(3, summaries.Count);
          Assert.AreEqual(expected1, summaries[0]);
          Assert.AreEqual(expected2, summaries[1]);
          Assert.AreEqual(expected3, summaries[2]);
      }
  </code></pre>
  
  <p><strong>Exceptions Detail</strong></p>
  
  <p>When using the first commented out line:</p>
  
  <pre><code>dynamic root = ServiceStack.Text.JsonSerializer.DeserializeFromString&lt;JsonObject&gt;(json);
  </code></pre>
  
  <p>This exception occurs when the method is called.</p>
  
  <p>NullReferenceException:</p>
  
  <pre><code>at ServiceStack.Text.Common.DeserializeListWithElements`2.ParseGenericList(String value, Type      createListType, ParseStringDelegate parseFn)
  at ServiceStack.Text.Common.DeserializeEnumerable`2.&lt;&gt;c__DisplayClass3.&lt;GetParseFn&gt;b__0(String value)
  at ServiceStack.Text.Common.DeserializeSpecializedCollections`2.&lt;&gt;c__DisplayClass7.  &lt;GetGenericEnumerableParseFn&gt;b__6(String x)
  at ServiceStack.Text.Json.JsonReader`1.Parse(String value)
  at ServiceStack.Text.JsonSerializer.DeserializeFromString[T](String value)
  at GitHubCommitAttemptTranslator.Tests.GitHubCommitAttemptTranslatorTests.TranslateFromGitHubToCommitMessage()
  </code></pre>
  
  <p>And, the second:</p>
  
  <pre><code>dynamic root = ServiceStack.Text.JsonObject.Parse(json);
  
  var summaries = new List&lt;string&gt;();
  
  foreach (var commit in root.commits) // &lt;-- Happens here
  </code></pre>
  
  <p>'ServiceStack.Text.JsonObject' does not contain a definition for 'commits'</p>
  
  <p><strong>Note:</strong> the message is 'string' does not contain a definition for 'commits' if I use code from line one, but change the type to  or to  instead of </p>
  
  <pre><code>at CallSite.Target(Closure , CallSite , Object )
  at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
  at GitHubCommitAttemptTranslator.Tests.GitHubCommitAttemptTranslatorTests.TranslateFromGitHubToCommitMessage()
  </code></pre>
  
  <p><strong>After using DynamicJson from .NET 4.0 ServiceStack</strong></p>
  
  <p>Referring to mythz's comment: 
  <a href="https://github.com/ServiceStack/ServiceStack/blob/master/tests/RazorRockstars.Console.Files/DynamicJsonTests.cs" rel="nofollow">This test case</a> works, but if I modify it like below:</p>
  
  <pre><code>var dog = new { Name = "Spot", Parts = new { Part1 = "black", Part2 = "gray" }, Arr = new [] { "one", "two", "three"} };
  var json = DynamicJson.Serialize(dog);
  var deserialized = DynamicJson.Deserialize(json);
  </code></pre>
  
  <p>Then, deserialized.Name and Parts are fine, but Arr is of type string.</p>
  
  <p>Also:</p>
  
  <p>If I use ' quotes it doesn't appear to work. Is that normal? json2 works (to the degree that Arr is also still a string), but json3 does not work at all. It just returns </p>
  
  <pre><code>Immediate Window:
  
  deserialized = DynamicJson.Deserialize(json3);
  {}
  base {System.Dynamic.DynamicObject}: {}
  _hash: Count = 1
  
  ----- code: -----
          var json2 =
              @"
          {
            ""Name"": ""Spot"",
            ""Parts"": {
              ""Part1"": ""black"",
              ""Part2"": ""gray""
            },
            ""Arr"": [
              ""one"",
              ""two"",
              ""three""
            ]
          }";
  
          var json3 =
              @"
          {
            'Name': 'Spot',
            'Parts': {
              'Part1': 'black',
              'Part2': 'gray'
            },
            'Arr': [
              'one',
              'two',
              'three'
            ]
          }";
  
          var deserialized = DynamicJson.Deserialize(json1);            
  </code></pre>