YouTip LogoYouTip

Json Intro

# JSON - Introduction * * * ## Online Example With our editor, you can edit JavaScript code online, then click a button to view the result: ## JSON Example

JavaScript Create JSON Object

Website Name:
Website URL:
Website Slogan:

var JSONObject= {"name":"Tutorial", "url":"example.com", "slogan":"Learning is not just about technology, but also about dreams!"}; document.getElementById("jname").innerHTML=JSONObject.name document.getElementById("jurl").innerHTML=JSONObject.url document.getElementById("jslogan").innerHTML=JSONObject.slogan [Try it Β»](#) Click the "Try it" button to view the online example. * * * ## Similarities with XML * JSON is plain text * JSON is "self-describing" (human-readable) * JSON has a hierarchical structure (values contain values) * JSON can be parsed using JavaScript * JSON data can be transmitted using AJAX * * * ## Differences from XML * No closing tags * Shorter * Quicker to read and write * Can be parsed using the built-in JavaScript eval() method * Uses arrays * Does not use reserved words * * * ## Why Use JSON? For AJAX applications, JSON is faster and easier to use than XML: #### Using XML * Read the XML document * Use XML DOM to loop through the document * Read values and store them in variables #### Using JSON * Read the JSON string * Process the JSON string with eval()
← Jquery Dom RemoveDom Validate β†’