JS object and JSON string format

Source: Internet
Author: User

1 <Head>2     <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" />3     <title></title>4     <Scripttype= "Text/javascript">5         varobj= NewObject ();6 obj. Name= "Eight Commandments"7 obj. Age=  -;8 9         //define objects in the form of literalsTen         varobj1= { "Name": "Eight Commandments", " Age": " -" }; One         vararr= [{ "Name": "Eight Commandments", " Age": " -" }, { "Name": "Eight Commandments 1", " Age": " +" }]; A  -         //JSON format: A JSON literal representation, as a string, or a JSON-formatted string -         varStr= '{"Name": "Eight Commandments", "Age": "$"}'; the         varJsonstrarr= '[{"Name": "Eight Commandments", "Age": "$"}, {"name": "Eight Commandments 1", "Age": "+"}];'; -          -         //converts a JSON string into a JS object (array) -         varResobj=json.parse (str); + alert (resobj. Name); -  +     </Script> A </Head> at <Body> - </Body> - </HTML>
Jsobandjson

JS object and JSON string format

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.