title: C++ Nested JSON in Unreal Engine 4
body: <p>I have a JSON object that I am getting from my server that looks something like this:</p>
  <pre><code>{
      &quot;state&quot;:&quot;1&quot;,
      &quot;player1&quot;: {
          &quot;alias&quot;:&quot;Player Name&quot;,
          &quot;ready&quot;:&quot;0&quot;
      }
  }
  </code></pre>
  <p>I am able to get the JSON, parse it into a FJsonObject, and retrieve any number or string in the first level of the JSON object using this code to serialize:</p>
  <pre><code>TSharedPtr&lt;FJsonObject&gt; JsonParsed;
  TSharedRef&lt;TJsonReader&lt;TCHAR&gt;&gt; JsonReader = TJsonReaderFactory&lt;TCHAR&gt;::Create(json);
  if (FJsonSerializer::Deserialize(JsonReader, JsonParsed))
      //Use JsonParsed
  </code></pre>
  <p>And this code to read strings:</p>
  <pre><code>FString AJSONContainer::getStringWithKey(FString key)
  {
      return storedJSON-&gt;GetStringField(key);
  }    
  </code></pre>
  <hr />
  <h2>Side Note:</h2>
  <p>AJSONContainer is just an Actor class that I use to call these functions from Blueprints.</p>
  <hr />
  <p>That's all fine and dandy, but when I try to read things from the second level, things don't work.</p>
  <p>I wrote this code to get the next level down:</p>
  <pre><code>TSharedPtr&lt;FJsonObject&gt; nested = storedJSON-&gt;GetObjectField(key);
  </code></pre>
  <p>But all calls to get fields of <code>nested</code> return nothing.</p>
  <pre><code>nested-&gt;GetStringField(anotherKey); //Nothing
  </code></pre>
  <p>So, for example, with the above JSON, this:</p>
  <pre><code>TSharedPtr&lt;FJsonObject&gt; nested = storedJSON-&gt;GetObjectField(&quot;player1&quot;);
  FString alias = nested-&gt;GetStringField(&quot;alias&quot;);
  </code></pre>
  <p><code>alias</code> has no value when I print it to the console.</p>
  <hr />
  <p>Am I doing something wrong? Why isn't the second-level JSON working?</p>