Skip to content

Instantly share code, notes, and snippets.

@amrelarabi
Last active January 16, 2024 16:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save amrelarabi/eff21c425072a4050bdadf2fa045041d to your computer and use it in GitHub Desktop.
Save amrelarabi/eff21c425072a4050bdadf2fa045041d to your computer and use it in GitHub Desktop.
var text = '{ "employees" : [' +
'{ "firstName":"John" , "lastName":"Doe" },' +
'{ "firstName":"Anna" , "lastName":"Smith" },' +
'{ "firstName":"Peter" , "lastName":"Jones" } ]}';
var obj = JSON.parse(text);
// وفى صفحة الويب
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML =
obj.employees[1].firstName + " " + obj.employees[1].lastName;
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment