title: JSON for Language Translation
body: <p>Fiddle: <a href="https://codepen.io/anon/pen/EvProJ?editors=1010" rel="nofollow noreferrer">https://codepen.io/anon/pen/EvProJ?editors=1010</a></p>
  
  <p>I'm trying to use a json object to set values and text stored in a JSON object</p>
  
  <p>I can do it fine this way....</p>
  
  <pre><code>var myJSON = { name:"Michael", age:25, city:"Chicago" };
  document.getElementById("demo").innerHTML = myJSON.name;
  </code></pre>
  
  <p>However, I'm having difficulty setting values and text stored in a JSON object. Like so...</p>
  
  <pre><code>var language = {
    eng: {
      hi: "Hello",
      bye: "Goodbye"
    },
    es: {
      hi: "Hola",
      bye: "Adíos"
    },
    fr: {
      hi: "Bonjour",
      bye: "Au revoir"
    }
  };
  
  console.log(JSON.parse(language.eng).hi);
  </code></pre>
  
  <p>Can someone explain what am I doing wrong and how can I set this text/values dynamically using this JSON object?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var language = {
    eng: {
      hi: "Hello",
      bye: "Goodbye"
    },
    es: {
      hi: "Hola",
      bye: "Adíos"
    },
    fr: {
      hi: "Bonjour",
      bye: "Au revoir"
    }
  };
  
  $('[data-language]').value = JSON.parse(language.eng).hi;</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  
  &lt;input type="text" data-language&gt;
  &lt;p data-language&gt;&lt;/p&gt;</code></pre>
  </div>
  </div>
  </p>