AJAX Made Easy - Learn AJAX



Frameworks Tutorials

 
Home Frameworks
 

Harnessing JSON Syntax

 

JSON’s affiliation with Ajax has frankly been overshadowed by XML. As a mark-up language specifically built for JavaScript, JSON should be on the frontline in developing Ajax based application. But JSON is overshadowed by XML because the former mark-up language is specifically built to JavaScript.


XML on the other hand, could be used on other programming languages. If a developer uses a framework in building an Ajax application, they would have trouble in building Ajax with the use of JSON since they would have to learn the programming language first.


With the use of framework, developers could easily use XML and build Ajax application without writing a single line of JavaScript.


But JavaScript cannot just be overshadowed by XML because of convenience. Aside from compatibility with JavaScript, JSON could work faster in developing an Ajax application because of its syntax. With the use of JSON, applications could be built faster since JSON has a very unique syntax.


As a markup language, JSON is supposed to be influenced by different variables. However, JavaScript could go slower because it has to receive variables from other sources. It might not mean much to speed, but coding has significantly shortened. Instead of variables, it will only have data which could be easily read.


Since JSON does not have the variables, it cannot be identified as an object that would influence the application. Developers that use JSON transforms the markup into an efficient object by adding eval () that will cover JSON.


But before it could be encapsulated in eval (), JSON has to be built as sJSON. This function allows JSON to become a variable which could be easily transformed into an object.


The JSON will basically end up in this form:


eval (“ (“ + sJSON + “) “)


You may notice that sJSON is covered with two curved brackets. The first curved brackets will enable the interpreter to identify them is an object while the second curved bracket will identify the coding as an evaluation.


However, this coding alone would not run since the identifier still has to know it is an expression to be evaluated. The solution to this is very simple as stated below:


= eval eval (“ (“ + sJSON + “) “)


That is right. By merely addition an equal sign before the eval would signal the interpreter that something should be read here.


The interpreter would easily read the application because it does not have to deal with a lot of codes and variables. By reducing (even removing) the variables, the Ajax application would execute faster.


The challenge in using JSON as an effective markup language, developers would have to build an application by hand. That means using a framework would be challenging.


Even if the framework is build with JavaScript, developers would have to deal with JSON by hand – which defeats the purpose of using a framework.


That is why JSON has been overshadowed by XML. But for developers who are proficient in JavaScript, familiarity with JSON syntax will really help in building an Ajax application.



Read Next: Yahoo User Interface 2.6.0



 

 

Comments



Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links