Pages

Death of ECMA 4 and future of Native JSON parsing



JSON is a subset of JavaScript.It is used to represent data as tokens of name - value pairs.This technology provides an efficient dataportability for mashable appliations.The JSON syntax is like JavaScript's object literal syntax except that the objects cannot be assigned to a variable. JSON just represents the data itself.Data is the string.This literal has to be converted to object.We can use eval() in Javascript to evaluate script.But using eval() is harmful.So a JSON parser will recognize only JSON text, rejecting all scripts.




If u need a javascript parser use ..

JSON.parse(strJSON) - converts a JSON string into a JavaScript object.
JSON.stringify(objJSON) - converts a JavaScript object into a JSON string.
Other parsers are

Jackson JSON Processor based on , STreaming Api for Xml processing .

JSON-lib is a java library for transforming beans, maps, collections, java arrays and XML to JSON and back again to beans and DynaBeans.

If you are using mozilla firefox and your browser supported above gecko 1.9, there is a regexp:test() function.

According to specification proposed by D.Crockford :

A JSON text can be safely passed into JavaScript's eval() function (which compiles and executes a string) if all the characters not enclosed in strings are in the set of characters that form JSON tokens. This can be quickly determined in JavaScript with two regular expressions and calls to the test and replace methods.

var my_JSON_object = !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(
text.replace(/"(\\.|[^"\\])*"/g, ''))) &&
eval('(' + text + ')');


This particular technology is alternative to XML to port data.The webservices implementations return XML data.The applications use parsers to generate native objects from these XML.XML is the data used in AJAX, which became the buzz in new age web.The data format is vital to the efficiency of any application.JSON provides an efficient data transfer.

Read JSON: The Fat-Free Alternative to XML

If you want to add JSON to application , read here how Yahoo webservices implemented this.

According to John Resig, browsers should support native json support,

He summarises that

The current, recommended, implementation of JSON parsing and serialization is harmful and slow. Additionally, upcoming standards imply that a native JSON (de-)serializer already exists. Therefore, browsers should be seriously looking at defining a standard for native JSON support, and upon completion implement it quickly and broadly.
Read here for the ECMA4 proposal

but now ?

ECMAScript 4.0 Is Dead


JavaScript standards wrangle swings Microsoft's way

The industry is again having war on browsers and internet standards.

So different methodologies to make JSON will be exist for some years on.As the system become complex, vulnerabilites will arise and we have to findout resolutions for those issues every time.

Need privacy ? Go for oAuth



In facebook we can import contact list from our mail accounts ... mmm Do you trust to give away your secret password?

Here comes the saviour ( hope !!)



An open protocol to allow secure API authentication in a simple and standard method from desktop and web applications.This API is very useful for the authentication mechanisms enabled by mashups/widgets.It is a Data Portability standard. The authentication method can help to port data between different web apps around.Most of the mashup technology widgets asks for the credentials from users for getting contact list,post links to bookmarks,blogs etc.Using the oAuth the users no longer need to give up their confidential Google accounts user name and password to 3rd party services in order for the 3rd party services to access their data on Google services.I thinks its more than OpenID.oAuth is now available for all Google Data APIs, everything from Gmail contacts to Google Calendar to Docs to YouTube.

Thus oAuth allows you to grant access to your private resources on one site to another site without sharing your passwords..

cool!


ReadWritreWeb Says:

Apps that don't use the approved Google user authentication method in short order will be acting like a mail carrier who says they have to have a key to the inside of your house to pick up your mail because they aren't familiar with the mailbox on the front porch.
Read Mashups: Google's Adoption Makes oAuth a Must Have for All Apps


oAuth.net says:

Everyday new website offer services which tie together functionality from other sites. A photo lab printing your online photos, a social network using your address book to look for friends, and APIs to build your own desktop application version of a popular site. These are all great services – what is not so great about some of the implementations available today is their request for your username and password to the other site. When you agree to share your secret credentials, not only you expose your password to someone else (yes, that same password you also use for online banking), you also give them full access to do as they wish. They can do anything they wanted –even change your password and lock you out.

This is what OAuth does, it allows the you the User to grant access to your private resources on one site (which is called the Service Provider), to another site (called Consumer, not to be confused with you, the User). While OpenID is all about using a single identity to sign into many sites, OAuth is about giving access to your stuff without sharing your identity at all (or its secret parts).

How does it work ?


If there is a service provider X (a mashup/widget/social app/bookmark app....) we have to get the resource data from them.The consumer C can have an app Y ,it can be a 3rd party widget, a desktop app or any other tool which is using the data from the service X. The consumer app Y has to be registered with the service X.



When the user decides to get the data,There will be a dialog between service and consumer getRequestToken(signed) will happen as

http://X/oauth/get_request_token

Then the user is directed to the service with the token and he is authorized

http://X/oauth/authorize.

Then user is send to the consumer site.Then there will be a dialog to exchange the request token for access token

http://X/oauth/get_access_token

Further communication will be based on this signed acesskey.

So the user neednot concern about the privacy as this form of "contract" exists between the consumer app and the service provider.

oAuth UX Flow :


A number of companies and individuals are working on solutions to this problem including Google, Yahoo and Microsoft, as well as the OAuth project. Initiated by Blaine Cook, Chris Messina, Larry Halff and David Recordon, OAuth aims to provide an open standard for API access delegation. The OAuth discussion group was founded in April 2007 to provide a mechanism for this small group of implementers to write the draft proposal for the protocol.

OAuth is already gaining considerable momentum, with implementations for many popular languages including Java, C#,Objective-C, Perl, PHP and Ruby. The majority of these implementations are hosted by the OAuth project via a GoogleCode repository. Sites supporting OAuth include Twitter, Ma.gnolia ,Photobucket and Google

First law for an unruly software programmer

All I want to do in life is code (!! or ?) mm... eat,sleep,have relationships (perpetual me-self),play a lot of computer games,read books..read read..research.. These thoughts became the fundamental principle for a "programmer" who didn't know about the laws of programming! Ha is there any laws to be followed ? The thermodynamics of a heated discussion on solving a bug within a team would have made revelations to some ... what if we have found out this bug early or why did we care less about the code block.. etc etc. I have a little experience about the spaghetti world of programming languages (being humble :P).

First law of programming says:

Lowering quality lengthens development time.

Yes.Its a good read.

We do a job, but we have to make the work best as we could.To err is human.We are in a rush to finish the task and impress our customer.IMHO , if we are able to solve the bugs step by step along with the development most of the issues will be solved.Ya, test driven development,agile,extreme programming ...
I think it will need experience by coding, code reviews we will be able find out bugs during development it self.Bug repositories, tracking etc could provide a checklist for the desired results.
Some people say that requirements are not fully achieved by the developed product , but some says we needn't give much importance to requirements .More importance to the code and the developed software.Make it smart.But we should know what we are making and what the customer will be expecting from the product.Are these requirements bullshit ? Read here

A good programmer will be a a good hacker.But if that guy is doing the hack-oriented programming, will the estimated scheduled will be met ? His job will be at a stake...? It depends upon a good manager :)

Some time the induced bugs can be lucrative sometime (the devilish side).Bug fixing prices !! I believe that's a bad way of service by providing the successfully "on-time" delivered product that sucks. Jolly customers !!

It all depends on what we are to develop and where we are.Happy programming.

RESTlet and REST in GWT



REST has been widely accepted as an architectural concept for web applications.Web 2.0 technology has became the backbone of future pervasive and distributed computing.When I went through some search on REST based application development for Java I came to know about Restlet framewok.Recently Restlet was ported to Google web toolkit.GWT is successful like the time when applet came to web world.This frontend technology from Google brings Java to web browsers.It uses GWT-RPC mechanism to invoke server methods.The port, named “Restlet-GWT module” that helps to leverage existing RESTful back-ends.Days back the team released its new milestone Restlet 1.1 M5
They have updated their wiki for the how-to documentation of developing applications based on the new enhancement.
There is another implementation to develop RESTful applications using GWT-REST
They can be used as a replacement or used along-side with GWT-RPC , I think that will make it very useful.




Jérôme Louvel, Restlet founder based in Levallois-Perret, France, has established the Restlet project to create a REST framework on top of the Java Servlet API to "bring the simplicity and efficiency of the REST architectural style to Java developers."He is the founder of Noelios Consulting