International Journal of Advance Engineering and Research Development. Refining Data Exchange Methodologies using JavaScript Object Notation

Similar documents
Web Application Security


Composer Help. Web Request Common Block

XML Processing & Web Services. Husni Husni.trunojoyo.ac.id

Assignment: Seminole Movie Connection

REST. Web-based APIs

User Interaction: jquery

A synchronous J avascript A nd X ml

CSC Web Technologies, Spring Web Data Exchange Formats

Copyright Descriptor Systems, Course materials may not be reproduced in whole or in part without prior written consent of Joel Barnum

RESTful -Webservices

DESIGN AND IMPLEMENTATION OF SAGE DISPLAY CONTROLLER PROJECT

Shankersinh Vaghela Bapu Institue of Technology

So, if you receive data from a server, in JSON format, you can use it like any other JavaScript object.

Networking & The Web. HCID 520 User Interface Software & Technology

AJAX Programming Overview. Introduction. Overview

Kyle Rainville Littleton Coin Company

TIME SCHEDULE MODULE TOPICS PERIODS. HTML Document Object Model (DOM) and javascript Object Notation (JSON)

Networking & The Web. HCID 520 User Interface Software & Technology

Chapter 10 Web-based Information Systems

Developing a Web Server Platform with SAPI support for AJAX RPC using JSON

CNIT 129S: Securing Web Applications. Ch 3: Web Application Technologies

This course is designed for web developers that want to learn HTML5, CSS3, JavaScript and jquery.

Introduction To Javascript Object Notation A To The Point Guide To Json

Developing Mobile Application Framework By Using RESTFul Web Service with JSON Parser

Working with Database. Client-server sides AJAX JSON Data formats Working with JSON data Request Response Bytes Database

Tooling for Ajax-Based Development. Craig R. McClanahan Senior Staff Engineer Sun Microsystems, Inc.

Ajax HTML5 Cookies. Sessions 1A and 1B

JAVASCRIPT JQUERY AJAX FILE UPLOAD STACK OVERFLOW

Copyright 2014 Blue Net Corporation. All rights reserved

2/6/2012. Rich Internet Applications. What is Ajax? Defining AJAX. Asynchronous JavaScript and XML Term coined in 2005 by Jesse James Garrett

Session 11. Ajax. Reading & Reference

AJAX ASYNCHRONOUS JAVASCRIPT AND XML. Laura Farinetti - DAUIN

AJAX. Lab. de Bases de Dados e Aplicações Web MIEIC, FEUP 2010/11. Sérgio Nunes

JSON is a light-weight alternative to XML for data-interchange JSON = JavaScript Object Notation

Web Engineering (CC 552)

Part of this connection identifies how the response can / should be provided to the client code via the use of a callback routine.

COURSE OUTLINE MOC 20480: PROGRAMMING IN HTML5 WITH JAVASCRIPT AND CSS3

Controller/server communication

XMLHttpRequest. CS144: Web Applications

AJAX: Introduction CISC 282 November 27, 2018

Lesson 14 SOA with REST (Part I)

UNIT-II : VIRTUALIZATION & COMMON STANDARDS IN CLOUD COMPUTING

16. Objects & JSON. Dr. Dave Parker. Informa;on and the Web, 2014/15

Active Endpoints. ActiveVOS Platform Architecture Active Endpoints

This tutorial will help you understand JSON and its use within various programming languages such as PHP, PERL, Python, Ruby, Java, etc.

CSC 337. JavaScript Object Notation (JSON) Rick Mercer

An Application for Monitoring Solr

Use of PHP for DB Connection. Middle and Information Tier

CENG 256 Internet Programming Draft

Space Details. Available Pages


DOWNLOAD OR READ : JQUERY AJAX JQUERY API DOCUMENTATION PDF EBOOK EPUB MOBI

Assignment #3 CSCI 201 Spring % of course grade Title Weathermeister Back-End API Integration

Developing RESTful Services Using JAX-RS

Data Access and Analysis with Distributed, Federated Data Servers in climateprediction.net

JavaScript CS 4640 Programming Languages for Web Applications

Global Servers. The new masters

Homework 8: Ajax, JSON and Responsive Design Travel and Entertainment Search (Bootstrap/Angular/AJAX/JSON/jQuery /Cloud Exercise)

CGS 3066: Spring 2015 JavaScript Reference

Developing Ajax Web Apps with GWT. Session I

CS WEB TECHNOLOGY

Creating and Working with JSON in Oracle Database

Comet and WebSocket Web Applications How to Scale Server-Side Event-Driven Scenarios

AJAX: Rich Internet Applications

Why Discuss JavaScript? CS312: Programming Languages. Lecture 21: JavaScript. JavaScript Target. What s a Scripting Language?

Introduction. Enterprise Java Instructor: Please introduce yourself Name Experience in Java Enterprise Edition Goals you hope to achieve

REST AND AJAX. Introduction. Module 13

Basics of Web. First published on 3 July 2012 This is the 7 h Revised edition

AJAX: From the Client-side with JavaScript, Back to the Server

10.1 Overview of Ajax

Rob Weir, IBM 1 ODF and Web Mashups

CS312: Programming Languages. Lecture 21: JavaScript

CT51 WEB TECHNOLOGY ALCCS-FEB 2014

IJSRD - International Journal for Scientific Research & Development Vol. 3, Issue 02, 2015 ISSN (online):

BEFORE CLASS. If you haven t already installed the Firebug extension for Firefox, download it now from

Introduction to Web Application Development Using JEE, Frameworks, Web Services and AJAX

Comprehensive AngularJS Programming (5 Days)

DOC // JAVA TOMCAT WEB SERVICES TUTORIAL EBOOK

Controller/server communication

Performance Testing: A Comparative Study and Analysis of Web Service Testing Tools

REST in Peace Mastering the JSDO with a Dynamic ABL backend. Mike Fechner, Consultingwerk Ltd.

AJAX. Introduction. AJAX: Asynchronous JavaScript and XML

PHP. MIT 6.470, IAP 2010 Yafim Landa

Jquery Ajax Json Php Mysql Data Entry Example

Web Application with AJAX. Kateb, Faris; Ahmed, Mohammed; Alzahrani, Omar. University of Colorado, Colorado Springs

Contents. Demos folder: Demos\14-Ajax. 1. Overview of Ajax. 2. Using Ajax directly. 3. jquery and Ajax. 4. Consuming RESTful services

Grading for Assignment #1

Introduction Haim Michael. All Rights Reserved.

AJAX Workshop. Karen A. Coombs University of Houston Libraries Jason A. Clark Montana State University Libraries

Table of Contents WWW. WWW history (2) WWW history (1) WWW history. Basic concepts. World Wide Web Aka The Internet. Client side.

Term Paper. P r o f. D r. E d u a r d H e i n d l. H o c h s c h u l e F u r t w a n g e n U n i v e r s i t y. P r e s e n t e d T o :

XPages development practices: developing a common Tree View Cust...

REST Easy with Infrared360

CS506 Web Design & Development Final Term Solved MCQs with Reference

Ajax Enabled Web Application Model with Comet Programming

Webservices In Java Tutorial For Beginners Using Netbeans Pdf

JavaScript CS 4640 Programming Languages for Web Applications

Writing REST APIs with OpenAPI and Swagger Ada

COURSE 20480B: PROGRAMMING IN HTML5 WITH JAVASCRIPT AND CSS3

Transcription:

Scientific Journal of Impact Factor (SJIF): 4.72 International Journal of Advance Engineering and Research Development Volume 4, Issue 4, April -2017 e-issn (O): 2348-4470 p-issn (P): 2348-6406 Refining Data Exchange Methodologies using JavaScript Object Notation Yogesh Kumar Das,Pulkit Jain B. Tech Computer Science Engineering, SRM University B. Tech Computer Science Engineering, SRM University Abstract When designing an application that will communicate with a remote computer, a data format and exchange protocol must be selected. There are a variety of open, standardized options, and the ideal choice depends on the applications requirements and pre-existing functionality. For example, SOAP-based web services format the data in an XML payload wrapped within a SOAP envelope.while XML works well for many application scenarios, it has some drawbacks that make it less than ideal for others. One such space where XML is often less than ideal is with Ajax-style web applications. While most browsers can construct, send, and parse XML, JavaScript Object Notation (or JSON) provides a standardized data exchange format that is better-suited for Ajax-style web applications.when the client is created with JavaScript in a browser it's much easier to exchange data with something called JSON. JSON is an acronym for JavaScript Object Notation. It is a sting-like notation that makes it easy to declare complex structures like arrays and object.json is a data exchange format that was created from a subset of the literal object notation in JavaScript.The charm of JSON is in its simplicity. A message formatted according to the JSON standard is composed of a single top-level object or array. The array elements and object values can be objects, arrays, strings, numbers, Boolean values (true and false), or null. Keywords-JSON;AJAX;Data feed; Remote procedure call; serialization; deserialization; Asynchronous calling I. INTRODUCTION JSON or JavaScript Object Notation is a very popular data interchange format. It was developed by Douglas Crockford. JSON is text-based, lightweight, and a human readable format for data exchange between clients and servers. JSON can be used in web applications for data transfer. Prior to JSON, XML wasconsidered to be the chosen data interchange format. XML DOM implementation made life tedious, as querying for data had to be performed at two levels: First on the server side where the data was being queried from a database, and the Second time was on the client side using XPath. JSON does not need any specific implementations.xml is much more difficult to parse than JSON.JSON is parsed into a ready to use javascript object. Languages such as PHP, Python, C#, C++, and Java provide a very good support for the JSON data interchange format. All the popular programming languages that support service-oriented architecture have understood the importance of JSON and its implementation for data transfer, thus, they have provided great support for JSON.A widelyused application of JSON is in mobile apps. Communication between the mobile device and the web server comes about by means of JSON calls. Data communication via JSON is such a popular method for mobile applications because the JSON data is so lightweight and can therefore be sent quickly and efficiently through a mobile connection.another commonly used application of JSON is in websites. JSON allows just parts of the web page, and not the entire page, to be refreshed and updated. This means the web browser can refresh a fragment of the web page with very little effort, giving the visitor a smooth online user experience II. DATA FEED A JSON feed is a data format in JavaScript and is used as a communication method between web browser and web server. The JSON data can be fed in different formats, such as simple type (both string and numeric) as well as complex type (like arrays and data objects). A data feedserves the purpose of JSON application; a feed is a crude way of supplying data so that others can reuseit to display the data on their websites or to ingest the data and run their algorithmson it. Such data feeds are big in size and cannot directly be embedded into the script. It can be retrievedeither as a response from an asynchronous request or from a JSON feed. @IJAERD-2017, All rights Reserved 177

III. ACCESSING OBJECT USING JSON To traverse through any JSON feed, it is important to make a note of how the data is arranged. There are two ways to access data in a JSON object: dot syntax or array notation. Dot-syntax: It is a way of indicating an object s property specifically, by adding a period between the name of the object and the property you wish to access. You ve seen this in use with properties of different JavaScript objects like strings and arrays. Dot notation is designed for easy, general use and common use cases. Queries of JSON data that use dot-notation syntax return JSON values whenever possible. If a single JSON value is targeted, then that value is the string content, whether it is a JSON scalar, object, or array. If multiple JSON values are targeted, then the string content is a JSON array whose elements are those values. The dotnotation syntax is a table alias (mandatory) followed by a dot, that is, a period (.), the name of a JSON column, and one or more pairs of the formjson_field orjson_fieldfollowed by array_step, where json_field is a JSON field name and array_step is an array step expression as described in Basic SQL/JSON Path Expression Syntax. Array Notification: To tackle an array of objects, we have to handle them in an iterative method. To resolve this we use an iterative solution in which we target one object at a time; once the object is accessed, we would not target that object another time. This allows us to maintain data integrity as we can avoid accessing the same object multiple times, thereby avoiding any redundancies. Image No 1 Steps for Invoking JSON-based Web Service IV. DATA TRANSFER INBETWEEN SERVER AND CLIENT 4.1. Server-Side Operations: 4.1.1. Data Transmission: Create JSONObject Java object Add name/value pairs using put method Convert it to String type using tostring method and send it to the client with content-type as text/xml or text/plain Example: mystring = new JSONObject (). put ( JSON, Hello, World! ).tostring(); // mystring is { JSON : Hello, World } 4.1.2. Data Reception: Read the JSON data as a String type Create JSONObject Java object from the string Example: String json = readjsonstringfromrequestbody(request); //Use the JSON-Java binding library to create a JSON object in Java JSONObjectjsonObject = null; try { jsonobject = new JSONObject(json);} catch(parseexceptionpe) {} 4.2. Client-Side Operation: 4.2.1. Data Transmission: Create JSON JavaScript object Use POST HTTP method in the open method of the XMLHttpRequest object Pass JSON JavaScript object in the send method of XMLHttpRequest object @IJAERD-2017, All rights Reserved 178

Example: varcarasjson = JSON.stringify(car); varurl = JSONExample?timeStamp= + new Date().getTime(); createxmlhttprequest(); xmlhttp.open( POST, url, true); xmlhttp.onreadystatechange = handlestatechange; xmlhttp.setrequestheader( Content-Type, application/x-www-form-urlencoded ); xmlhttp.send(carasjson); 4.2.2. Data Reception: JSON data is received as a string Calling eval() will generate JSON object in JavaScript code varjsondata = eval(req.responsetext); Once you have JSON object, you can use. notation to access its properties var name = JSONdata.name; var address = JSONdata.addresses[3]; varstreetname = JSONdata.addresses[3].street; V. MODIFYING JSON JSON retrieved from a JSON feed is always going to be read-only; as such data feedsdo not provide functionality to modify their data from unverified sources. There are many cases where we would want to ingest the data from an external data feed, and then modify that content as per our requirements.json provides us with features which help modify json objects that represent json arrays and object. Json declare the following set() methods for modifying json array elements and json object properties: Json set(int index,object value) Json set(string propname,json value) Json set(string property,object value) string json = @"{ 'channel': { 'title': 'Star Wars', 'link': 'http://www.starwars.com', 'description': 'Star Wars blog.', 'obsolete': 'Obsolete value', 'item': [] } }"; JObjectrss = JObject.Parse(json); JObject channel = (JObject)rss["channel"]; channel["title"] = ((string)channel["title"]).toupper(); channel["description"] = ((string)channel["description"]).toupper(); channel.property("obsolete").remove(); channel.property("description").addafterself(new JProperty("new", "New value")); JArray item = (JArray)channel["item"]; item.add("item 1"); item.add("item 2"); Console.WriteLine(rss.ToString()); VI. AJAX CALLS WITH JSON DATA In AJAX (AsynchronousJavaScript and XML), web requests are made via JavaScript and the data interchangeoriginally happened in XML. The "X" in AJAX was originally considered to be XML,but today it can be any data interchange format, such as XML, JSON, text file, oreven HTML. The data format being used for the data transfer has to be mentionedin the MIME type headers. @IJAERD-2017, All rights Reserved 179

Dynamic web development is all about data transfer between two parties, the client and the server. We use programs such as a web server, a database, and a server-side programming language to fetch and store dynamic data. In AJAX (Asynchronous JavaScript and XML), web requests are made via JavaScript and the data interchangeoriginally happened in XML. Asynchronous requests allow developers to divide web pages into multiple components independent of each other, thereby saving a lot of memory by sending data on demand. Table No 1 Basic AJAX call sample code for server and client-side application Table No 2 Description of various Ajax properties @IJAERD-2017, All rights Reserved 180

VII. JSON-REMOTE PROCEDURE CONTROL JSON-RPC is a simple remote procedure call protocol similar to XML-RPC although it uses thelightweight JSON format instead of XML. JSON-RPC-Java is a Java implementation of the JSON-RPC protocol. It allows you to transparently call server-side Java code from JavaScript with an included lightweight JSON- RPC JavaScript client It is designed to run in a Servlet container such as Tomcat and can be used with J2EE Application servers to allow calling of plain Java or EJB methods from within a JavaScript DHTML web application Image No 2 Asynchronous Interaction Using AJAX VIII. EXPERIMENTAL EVALUATION In this section, experiments were employed to verify the performance of the DMT driven JSON processingapproach. It was compare with that of the XML-based web services. Experiments were conducted on a PCwith 1.73 Intel Core Duo CPU, 2GB Memory installed with Windows XP Profession SP3. The JVM used is JDK1.6.0 and Apache Tomcat 5.5 was exploited as the Web container. XML and JSON data wasparsed with Simple 2.5.2 and Jackson1.7.6, respectively. Experiments were conducted to investigate the scalability of serializing/deserializing java data objects to/from JSON and XML data objects. The time was measured for serializing/deserializing as the size of data objects changed from 2kb to 12kb. Graph No 1 (a) Comparison of Serialization (b) Comparison of Deserialization Graph No1: Comparison of Scalability between JSON and XML @IJAERD-2017, All rights Reserved 181

Graph No1 presents the result of the experiments. Graph No 1(a) describes the measurement of time needed for the serialization of Java data objects to JSON/XML. From the figure, we can see that, the time needed for serializing java data objects both increases to JSON and XML data objects. However, for JSON data, it increases much slower than that for XML data, which means the scalability for using JSON as the data format for exchanging has better performance than using XML. Graph No1(b) illustrates the deserializingjson/xml data objects to java data objects. Similar to serialization, the performance of deserializingjson data objects to java data objects has surpassed that of deserializing XML data objects to java data objects. REFERENCES [1].Drew Adams, Oracle Database JSON Developer s Guide, 12c Release 2(12.2) E85247-01,Feb 2017 [2]. Sai Srinivas Sriparasa, Javascript and JSON Essentials, PACKT Publishing,ISBN-10: 1783286032, January 2013, pp.45-60. [3]. Jeff Friesen Java, XML and JSON,Apress Publication, ISBN 978-1-4842-1916-4, June 2016,pg-165-177. [4]. Chen-Hsiang (Jones) Yu AJAX and JSON with jquery, CSAIL(MIT Press Bookstore), Jan 2010. [5]. D. PENG Boas, L. CAO and W. XU.Oliveira, Using JSON fordata Exchanging in Web Service Applications, Journal of ComputationalInformation Systems 7:16, 2011, 5883-5890. [6].Sang Shin, Introduction to JSON, Sun Microsystem Inc. @IJAERD-2017, All rights Reserved 182