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