How to Access/Parse Json in Javascript

In javascript we can use json parser to parse json values. JSON.parse() take string as an argument and return an object.

Subscribe Our Tutorials

Get Latest Updates on Facebook

How to Parse Json in Javascript

Let’s create one json string and stored in a variable.

To parse json data, we are using JSON.parse().It take as a string and return object.

If you want to check what empValue variable contains, you can print

If you want to check whether it’s an valid json or not

Print object values, here i am using for/in loop.

If you want to access individual property of an object , you can do it by


About WebRewrite

I am technology lover who loves to keep updated with latest technology. My interest field is Web Development.
Tagged , , . Bookmark the permalink.
  • Doesn’t JSON.parse(empData); throw an exception if the json is invalid ?
    I don’t think the following is a valid check:
    if (typeof empValue == ‘object’)

    using a try… catch around the JSON.parse is the best way to check for invalid JSON.
    Would you agree ?