Parse JSON in JS

Source: Internet
Author: User

Reference: http://www.stylejar.com/archives/js%E5%AF%B9%E8%B1%A1-%E6%95%B0%E7%BB%84-json-%E4%BA%92%E7%9B%B8%E8%BD%AC%E6%8D%A2.html

Http://ayanline.iteye.com/blog/920061

Http://blog.csdn.net/lushuaiyin/article/details/7096522

Http://www.cnblogs.com/codeplus/archive/2011/07/18/2109544.html

 

Sometimes the JSON returned by the background is not actually a real JSON. For JavaScript, it is equivalent to a string and needs to be converted to a real JSON.

VaRT="{'Firstname': 'cya', 'lastname': 'chardson ', 'address': {'streetaddress': '1 Microsoft way', 'city ': 'redmond ', 'state': 'wa', 'postalcode': 98052}, 'phonenumbers ': ['2017-777-7777', '2017-777-7777 ']}";VaRJsonobj=Eval('+ T + ')');

For example, you want to obtain the firstname after the conversion. You can directly obtain internal parameters using jsonobj. firstname.

Eval is a built-in JavaScript method.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.