Object Serialization Using Json Computer Science Essay

Published:

This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.

In this paper, it has been discussed about the current technological era of data transmission and object serialization in web application. This paper will gives the analytical research in the form of two data serializing approaches used in web applications, which are 'Extensible Markup Language' (XML) and 'Java Script Object Notation' (JSON). The working methodologies for both the approaches are different depending on the browse's Document Object Model (DOM) and both are highly efficient in their own working criteria. But still developers are getting in trouble while choosing the best technique for the comfortable and secured data transmission and object serialization between two objects. The key features of these two techniques are to analyze all data objects and it was pointed out that how to translate data correctly between these two objects. These approaches affect 'Asynchronous JavaScript and XML' (AJAX), which is a technique used in the web application for transmitting and receiving chunks of data on the webpage between client and server. This AJAX technique will use both these approaches for efficient data transmission asynchronously (ongoing background process) without disturbing the current content on the webpage. In this paper, it is also described about the implementation of both this approach in various web browsers. From this research, developer will come to know about the detailed usage of both the approach with respect to their web application.

KEYWORDS:

Extensible Markup Language (XML), Asynchronous JavaScript and XML (AJAX), Web Application, Asynchronous Transmission and Receiving Technique, Document Object Model (DOM)

Introduction

In the current technological era of web application, many developers are using two very common and useful approaches that are Extensible Markup Language (XML) and JavaScript Object Notation (JSON). Both those approaches are used while transmitting the data among various web application objects which uses web services or even Asynchronous and JavaScript and XML (AJAX). Thus it's all depending on the developer to choose any one specific platform or technique for serialization, which suits better in their web application criteria. This choice will make the application more capable and durable in data transmission and object serialization.

The problem arises when one needs to send data to other local service or any application deployed on the third party server which does not support the approach that sender application following. That time application developer need to provide better solution with proper XML and JSON translation with specific implementation. Here when sender transmits the data, it will be translated to another approach format with various functional methods that are similar to the data translation. That is how this particular problem got the better solution using those methods.

In some condition when the translation takes place, it also generates unnecessary data such as duplicates or junked data inform of functions or methods. That time one need to follow very concrete and common solution that overcomes the effect of distorted information. Further in this paper, it is included the detailed analytical research based on the proposed problem scenario using XML and JSON both the approaches.

XML and its Data Structure

Extendible Markup Language known as XML is inborn from the Standard Generalize Markup Language (SGML). XML represents no processing specification rather it describes what information should be provided using particular attribute name. XML is a machine readable and human understandable language which follows text/document type format with some set of rules and standards given by the W3C (World Wide Web Consortium).

XML provides huge support to web application and emphasize the durability, reusability, accuracy, simplicity and many more things to each web service. XML mainly used for data transmission and object serialization purpose where one can extend the data or document as when as required in a very simpler way. It is used in the place where most of the application having different platform that is how it is called as cross platform homogenizes language that is acknowledged by industry moral. Here is an example that describes how the XML represents various elements in different hierarchy.

<? xml version="1.0" encoding="UTF-8"?>

<branch name="mca">

<student>

<regid>

11MCA0039

</regid>

<fname>

Siddharth

</fname>

<lname>

Jogia

</lname>

</student>

<student>

…

…

</student>

</branch>

As per the data structure of XML, all information should lies between closed tags. This document is then parsed by an XML parser which uses Document Object Model (DOM) Interface which allows map reading of the complete file just like a tree of object nodes. DOM has its own application programming specification such as its nodes are nonconcrete, memory rigorous implementation, object mapping and binding, for all this features first it needs to be made like a tree model then only it can get access. Thus, it follows a tree structure for data representation the following model is the tree structure model for the above example.

Branch - MCA

Student

Regid

Fname

Lname

Fig 1: Tree Model Structure of XML

JSON and its Data Structure

JSON stands for JavaScript Object Notation which is a text oriented undefended standard that is specifically designed for human understandable format to interchange chunks of data. This technique was developed on the core basis of java script language, and is focused on its main concept simple structure and array with associative key values known as array objects. This approach is independent of any language as it follows the core functionality of any programming language. Therefor many applications programming language can directly support its parsers that are available for it without configuring additional API for JSON.

In contrasting to XML, JSON is very informal in reading and writing, it has friendlier programming interface, it is not heavy as compare to XML interchange design; more essentially, one can simply generate or parse without giving much efforts, which allows Ajax engine to ensure more efficient data translation. JSON is grounded on a subdivision of JavaScript, exhausting the text design layout that entirely autonomous in any programming technology, still it encapsulate the same terminology that a basic programming language follows such as C, Java, C#, Php and many more. These possessions define JSON rapidly and become a common documents exchange or translation format.

JSON defines document object primarily in two ways: objects and arrays. The JSON array is a well-arranged combination of keys and values. Starting of the array will always be "[" and ending of the array will be "]", and the key and value pairs in the array are divided using ','. Object in the JSON is a random combination of key-value sets; its notation is related with the java's object map. In JSON, An Object will always begin with "{" and terminates with "}", all key name is succeeding with a ":", and all key-value sets are divided by ",". Both data structures are shown in below figures.

C:\Users\REVOLUTION\Desktop\json array structure.JPG

Fig 2: JSON Array type structure

C:\Users\REVOLUTION\Desktop\json obj structure.JPG

Fig 3: JSON Object type Structure

As the above mentioned example of XML, JSON can be defined the exact data format but in its own style which is as follows:

{

"Branch-MCA":

{

"student": [

{

"regid": "11MCA0039",

"Fname": "Siddharth",

"Lname": "Jogia"

},

{

….

….

} ]

}

}

First this object of JSON will be parsed by the JSON parser and then it is converted in to the single string which defines the exact object created before, after that it will be transferred to another layer. After successful analysis of both JSON and XML structure one could make sure that the structure of JSON is more efficient in data serialization which follows key-value sets where as in XML the enclosed tags will be discarded and use it keys and values only. As shown in Fig 1, JSON as well as XML both follows the same tree structure based model.

AJAX in Data Transmission

Asynchronous Java Script and XML known as AJAX is a collection of correlated web technology that is implemented on the user side which makes asynchronous network applications. One could use this technology when there is no need of client interaction which means that user can continue with his work and without being disturbed this technology will send the data or receive the data based on the required operation from the external server. Therefor Ajax is asynchronous language which will not give effect in the display of front end page and even will not change the current going page's behavior. To implement this technique one need to use two basic procedure of AJAX library which are ajax_request(), ajax_response() or one could also use XMLHttpRequest() for XML type communication.

Ajax is made up of multiple techniques which consist of HTML, CSS, Javascript or XML. Here HTML will give a platform of any web application and CSS will provide an attractive design to that application. The Document Object Model is contact with JavaScript allowing the web page interacts with the user dynamically. In combination with XML and JavaScript one can provide the asynchronous behavior of the webpage which denies the page load at every time user interacts with the server.

C:\Users\REVOLUTION\Desktop\Ajax.JPG

Fig 4: AJAX workflow

Ajax Engine works as a middleware between Client Browser (User Activity) and the Server Process. Here user activity will not disturbed while transmitting or receiving any information. Java Script will raise a request to Ajax Engine and Ajax does the data transmission with server process and returns back the response to the client browser and display the output asynchronously.

Ajax Framework - JSMX

JSMX is a very powerful platform which can be consider as the most commonly used framework of AJAX Language. Using this framework, One can easily implement the basic technique of Ajax into any web based application. Unlike other framework of Ajax, this framework API used more widely in the world of Ajax, as it has no component which relies on the server part. Therefor mostly used components are installed on the user side only to run the application efficiently. Even by using this, one can return the response in the most common way those are JSON, JavaScript, WDDX or XML.

The JSMX API structure diagram is shown in Figure 5 below. To use this framework, one needs to put its engine file that is ajaxengine.js into their webpage. Then by calling Javascript function, client can forward the request to server and can get the response back. While making request, one need to specify the exchange method that can either be POST or GET, and placed in the argument list of the http() method which can be founded in the engine.js library file. Server accept the request and do the required process with the server data and give response back to client in the above said forms and display the result in the java script object form and placed it into the actual running webpage.

C:\MCA 4th Sem\SET\Webpages\JSMX - The Universal Ajax API for ColdFusion, PHP, .NET, or your language of choice._files\JSMX_API.jpg

Fig 5: Ajax Engine - JSMX Framework API

Web Application Data Conversion

Algorithm for Transformation

As it has been discussed in the above topics that JSON and XML both approaches follows multi-branch tree type arrangement. Thus to do translation from XML to JSON one need to parse the entire xml file using xml parser and store the respective data items into an array type object using any recursive traversal algorithm. In general that algorithm can be described by the following steps:

Find the tree object with the absolute root of the given xml tree

Access the root node and take its value in some variable.

If the returned value of the current node has multiple leaf nodes then go through all its sub nodes and do data fetching operation from all sub roots.

If the current node is a leaf node then return the value

Now make the root node value as a JSON object key and make their leaves as the values of that object which is correlated with the given keys.

By applying the above said algorithm one can easily transform the XML format into JSON format.

Usage of Translation in Web Service

Application Web Service mostly relies on the third party application server and most of them are following the XML schema format as web service play very small role in any web application. Thus one has to do serialization of XML based service into local JSON service. Initially the third party application server send XML schema object to the local server, and then local server need to do serialization in order to get its respective JSON format. Thus, to implement this transformation factor, one needs to add the following architecture in their existing application. This sub system plays an intermediate role which translates XML to JSON and returns the result back to local client

The translation architecture is shown in Fig 6.

C:\Users\REVOLUTION\Desktop\web service.JPG

Fig 6: Translation in Web Service

Here in this system, translation method in the layer of processing data in the local server cannot make direct connection with the third party's web service. So the new layer attached to the main application called as translation layer. Now the problem of translation can be solved as because of this additional layer.

This layer will take the data from the third party and translate the data and then integrate the output and send it to the correspondent recipient. By this way the translation in the web service can be done with the help of additional layer correlate with the data processing unit.

Translation in Ajax base Application

Ajax technique base applications are generally intended for increasing the user involvement where the data sending quickness is the key factor. For this one need to use java script correlated with the JSON format in the particular Ajax framework as they both are very much compactible with each other. As discussed above that the JSON is very efficient in analysis and transmitting or serialization of data, one can also achieve that benefits of JSON incorporates with the Ajax application. In some scenario, one may use XML or any other type of data format in their application, so in order to get any data from that third party server is quite difficult when the data exchange format is different at both the ends. If it is different than the recipient data format then one need to do translation from that format to his particular format. The solution architecture is as follows:

C:\Users\REVOLUTION\Desktop\ajax app.JPG

Fig 7: Translation in Ajax based Application

Here above is the architecture diagram of translation process. In this, it is same with thing happens with web service also, one needs to add additional translation later in the local server in order to get the same type of data format from third party application server. And unlike in web service, one can give response to the current working web page by using the technique of Ajax with the JavaScript and JSON for speed up transmission and the serialization.

As discussed above, XML is little time consuming while parsing up the data or transmitting the data, thus it is beneficial to use JSON format to speed up the response time or application throughput.

Here in Ajax based application, one needs to provide the translation method in an additional layer called translation layer. This layer will get the data in form of Ajax request and receives the third party data, and then it does translation and integrates the output in the result JSON string and responds to the browser. All this process will be done asynchronously that is without disturbing the user activity in the local server. As this is the main goal of Ajax they it behaves unknowingly to the client in the background.

After such translation the browser receives the JSON string and parses the string to its native language that is in Java Script and displays the correspondent data items to its relevant part in the html page using java script document object model. This is how the translation can be used in the in the local server and third party server using Ajax.

XML vs. JSON- Benchmarking

As it has been discussed earlier in this paper about the use and different data structure of XML and JSON in the AJAX technology, the benchmarking could be taken in term of response time while accessing a single particular object from the hundreds of similar type of object in the whole document. For this purpose www.navioo.com has done very useful benchmarking on JSON and XML for the same chunk of data. They have attested these approaches with 1000 no of rows and get the result in different browsers such as Firefox, IE, Chrome, and Safari. The analyzed data in two different scenarios, first scenario has two column and second scenario has four columns, which are shown in the below table.

C:\Users\REVOLUTION\Desktop\benchmarking.JPG

Table 1: Benchmark Report

Thus from this benchmarking, one can easily measure the speed of data transmission and serialization in most of the common browsers. From the taken test, it has been proved that usage of JSON is better than the XML as the file size as well as its object access time is very low as compare to XML type of structure.

Conclusion

After this much analysis, one can easily say that use of JSON technique over the XML format for the data transmission and object serialization is much more better in the real world Ajax based web application. By looking at the tree structure, both are the same in its structure model but the usage and working strategy is completely different than each other. One can use the above given algorithm for data translation from XML to JSON when and where it is required. This will definitely optimize the efficiency and the overall speed of any web based application and makes it more malleable and appropriate. Thus by looking into all aspect discussed in this paper, one can get the detailed view of both the technologies and can be able to decide when and where to implement particular technique.

Writing Services

Essay Writing
Service

Find out how the very best essay writing service can help you accomplish more and achieve higher marks today.

Assignment Writing Service

From complicated assignments to tricky tasks, our experts can tackle virtually any question thrown at them.

Dissertation Writing Service

A dissertation (also known as a thesis or research project) is probably the most important piece of work for any student! From full dissertations to individual chapters, we’re on hand to support you.

Coursework Writing Service

Our expert qualified writers can help you get your coursework right first time, every time.

Dissertation Proposal Service

The first step to completing a dissertation is to create a proposal that talks about what you wish to do. Our experts can design suitable methodologies - perfect to help you get started with a dissertation.

Report Writing
Service

Reports for any audience. Perfectly structured, professionally written, and tailored to suit your exact requirements.

Essay Skeleton Answer Service

If you’re just looking for some help to get started on an essay, our outline service provides you with a perfect essay plan.

Marking & Proofreading Service

Not sure if your work is hitting the mark? Struggling to get feedback from your lecturer? Our premium marking service was created just for you - get the feedback you deserve now.

Exam Revision
Service

Exams can be one of the most stressful experiences you’ll ever have! Revision is key, and we’re here to help. With custom created revision notes and exam answers, you’ll never feel underprepared again.