Become a fan of Slashdot on Facebook

 



Forgot your password?
typodupeerror
×
Java Programming The Internet IT Technology

What is JSON, JSON-RPC and JSON-RPC-Java? 317

Michael Clark writes "Seen those funky remote scripting techniques employed by Orkut, Gmail and Google Suggests that avoid that oh so 80's page reloading (think IBM 3270 only slower). A fledgling standard is developing to allow this new breed of fast and highly dynamic web applications to flourish. JSON (JavaScript Object Notation) is a lightweight data-interchange format with language bindings for C, C++, C#, Java, JavaScript, Perl, TCL and others. It is derived from JavaScript and it has similar expresive capabilities to XML. Perfect for the web as doesn't suffer from XML's bloat and is custom made for our defacto browser language. JSON-RPC is a simple remote procedure call protocol similar to XML-RPC although it uses the lightweight JSON format instead of XML (so it is much faster). The XMLHttpRequest object (or MSXML ActiveX in the case of Internet Explorer) is used in the browser to call remote methods on the server without the need for reloading the page. JSON-RPC-Java is a Java implementation of the JSON-RPC protocol. JSON-RPC-Java combines these all together to create an amazingly and simple way of developing these highly interactive type of enterprise java applications with JavaScript DHTML web front-ends. " Click below to read more about it.
"Now is the turning point. Forget that horid wait while 100K of HTML downloads when the application just wanted to update one field on the page. The XMLHttpRequest object has made it's way into all the main browsers with it's recent introduction into Opera and Konqueror (sans the Konqueror bug). This new form of web development now works on Internet Explorer 5, 5.5, 6, Mozilla, Firefox, Safari 1.2, Opera 8 Beta and Konqueror 3.3 (with a much needed patch). Appeal to Konqueror users - please log into the KDE bugzilla and vote on this bug so you to can experience this wonderful thing. More details here: http://oss.metaparadigm.com/jsonrpc/ "
This discussion has been archived. No new comments can be posted.

What is JSON, JSON-RPC and JSON-RPC-Java?

Comments Filter:
  • Pros and cons? (Score:5, Interesting)

    by Sierpinski ( 266120 ) on Monday January 24, 2005 @09:35AM (#11454634)
    Two major issues that come to mind with this type of technology:

    1) How easy is it to learn for the average programmer

    2) What kind of security precautions can we expect to see?

    Otherwise it sounds like a great technology to use for web developers who wish to have dynamic content on their sites.
  • by Anonymous Coward on Monday January 24, 2005 @09:43AM (#11454683)
    XUL and XAMAL are being developed so that all applications WILL run through the intarweb...

    Only computationally expensive programs will be relegated to the desktop, everything data orientated will live on the web
  • And what about php? (Score:2, Interesting)

    by Anonymous Coward on Monday January 24, 2005 @09:43AM (#11454686)

    If you want to interoperate with PHP, I'd suggest Harry Fuecks JPSPAN [sourceforge.net] as it is quite nice at hooking javascript up with serverside php

    As for xmlhttprequest, it's rather easy to make neato web applications with it. Here's something I coded up the other night (only seems to work in firefox at the moment though): http://www.james-carr.org/index.php?p=8



    Cheers,
    James Carr [james-carr.org]
  • by Anonymous Cowherd X ( 850136 ) on Monday January 24, 2005 @09:44AM (#11454695) Journal

    Example in JSON:

    {"menu": {
    "id": "file",
    "value": "File:",
    "popup": {
    "menuitem": [
    {"value": "New", "onclick": "CreateNewDoc()"},
    {"value": "Open", "onclick": "OpenDoc()"},
    {"value": "Close", "onclick": "CloseDoc()"}]}}}

    The same thing in XML:

    <menu id="file" value="File" >
    <popup>
    <menuitem value="New" onclick="CreateNewDoc()" />
    <menuitem value="Open" onclick="OpenDoc()" />
    <menuitem value="Close" onclick="CloseDoc()" />
    </popup>
    </menu>

    Perfect for the web as doesn't suffer from XML's bloat and is custom made for our defacto browser language.

    Take a look at those examples and try to explain how is JSON free from bloat when in fact it is even more bloated and slightly more difficult to read and write by humans? It's just another notation with no obvious advantages.

  • by Malc ( 1751 ) on Monday January 24, 2005 @09:50AM (#11454731)
    Web interfaces have two massive advantages: no need to install anything. They also work just about anywhere.

    You're right: a web page for a complicated will rarely match the UI of a dedicated application. Take Outlook's Web Access UI: it's pretty amazing, especially if you're using IE. It can be used almost anywhere without having the latest version of Office installed. It's still damned clunky compared with real Outlook, but sometimes it's better than nothing.
  • Re:Fix HTML instead? (Score:4, Interesting)

    by TheRaven64 ( 641858 ) on Monday January 24, 2005 @10:01AM (#11454806) Journal
    I don't think HTML is to blame so much as HTTP. The integration of something like XMPP into the browser would be a huge improvement, since it would allow arbitrary XML to be pushed to the client without the need for polling (which is ugly, and no less ugly if it's done in the background without the need for full page refreshes.
  • by stanhawkins ( 852794 ) on Monday January 24, 2005 @10:03AM (#11454815)
    We've written a client for the Remedy Action Request System using JS and the XMLHttpRequest object, with a Java based back end. The client is faster than we ever imagined, and is twice as fast as Remedy's own client. So if you fancy seeing some Shockwave movies of a overly complex web client, which demonstrates exactly what can be achieved with the XMLHttpRequest object, visit: http://www.symbiontsolutions.com/tour Stan
  • Re:O...k..... (Score:5, Interesting)

    by rdc_uk ( 792215 ) on Monday January 24, 2005 @10:32AM (#11455048)
    "So now people can't bookmark specific products"

    Fair comment, though I can think of places where similar features are desirable -> changing product images is a better usage.

    "Useful from a commercial point of view. Really rather distracting from a visitor point of view. If I can't block it, I'm likely to find another vendor."

    Good luck; sites designed to sell tend to ADVERTISE their wares. You seem to be thinking 3-second rotation; I'm thinking more 1-minute rotation of current "specials". Put bluntly; I have clients that will pay me to do this if its possible.

    "This sounds practical, but at some stage you need to send the user to a new page anyway, and you can calculate new totals without having to make server calls."

    1; I don't want the mechanism for calculations at the client side, so the calculation would require a reload, therefore this will make the page more responsive; i.e. better. The reason for non-client side? First: javascript is a shit language for anything other than DOM manipulation. Second: clients don't want their business logic exposed in javascript. Third: we don't want to download all the data required for those calculations to the client (prices in a code-manipulatable form should NEVER get to the client side, or be sent via post/get, prices just get displayed to the client, not manipulated by them)

    Think about a checkout that calculates shipping costs globally; you need the location from the client. Depending on location the methods available for shipping will change. Depending on weight of goods (changes with quantity change) and location, the costs for each method change.

    Thats a LOT of information to download to the client's machine to make the totals update without a server-call. Its also a ton of information (including prices) that I don't want the client side to have access to, and that I don't want javascript responsible for calculations on.

    If I can pull down just the new value, rather than the whole page -> better!

    "Ummm... why would you want an RSS new ticker on a webpage in the first place?"

    Again; clients will pay for it. Just because YOU don't want it (or, in fact, that my client's clients don't want it), doesn't mean it has no value.

    "Yes, lets just create something with no practical advantages over Flash/Iframe, but which requires a more recent browser to access."

    There are plenty of advantages to not using flash. (reduce number of languages required to display 1 page and reduce number of external plugins required to display 1 page to name just 2 advantages)

    Iframes are never a good idea.

    And did you read the list of supported browsers? Only notable omission in the real world was safari...
    2;

  • by ivec ( 61549 ) on Monday January 24, 2005 @10:37AM (#11455085) Homepage
    The previous does choose a best-case format for XML, relying on attributes instead of elements whenever possible. To be honest, what would be the actual SOAP encoding for the equivalent JavaScript data structure?

    Now what would you think of (dropping quotes and spaces when unnecessary for parsing):
    {menu:{id:file;value:"File:";
    popup:{menuitem:({v alue:New;onclick:"CreateNewDoc()"}
    {value:Open;on click:"OpenDoc()"}
    {value:Close;onclick:"CloseDoc ()"})}}}
    Now what if built-in filter allowed you to generate either this compact blurb, or a neatly auto-formatted and indented form?

    The JSON format (which I just discovered) is nearly identical to a format I have been using for 10+ years - with which this sample is compatible. The i/o implementation I use internally is in C++, and supports a binary, compressed, and encrypted formats as well. An incomplete rewrite of it in C is available at http://ivan.vecerina.com/code/datatree/ [vecerina.com].

    I like JSON more than XML - because it offers a natural representation of hierarchical data structures seen most languages: a tree of records(/objects), arrays(/collections), and leaf values(/simple data fields).

    XML has many qualities, but it is not the natural solution/format for such data structures. When should text data be used in XML? When should you use an element rather than an attribute in XML?
    XML forces you to either select a standardized mapping that introduces redundant clutter (SOAP), or accept the complexity of an application-specific mapping.
  • Re:O...k..... (Score:3, Interesting)

    by dorward ( 129628 ) on Monday January 24, 2005 @10:49AM (#11455197) Homepage Journal

    So (some) Vendors want it, and (some) Web Developers want it becuase the Vendors (their clients) want it - but does it bring any serious benefit to the end user?

    Changing product images is a reasonable thing to do - but all that needs is a change in the src of the <img> (Or you can take the thinkgeek approach and have nice, large images that show lots of details and that a full page reload doesn't add any significant bandwidth needs to)

    1-minute rotation? How long to people spend on a single page that they aren't reading carefully (and don't want to be distracted)? Just pick a special at random with each new page. Amazon has a "related produts" which works rather well IMO.

    I accept your point about the price calculations, for things where the postage et al isn't simple there could be some benefit. However, do people really fiddle the quantities up and down so much that the occasional reload is going to be a noticable detraction of service?

    I can't say that I'm really pro-Flash or pro-Iframes (OK, I'm very much against them), but you say "Iframes are never a good idea." without giving any reasons - I can think of quite a few reasons why Iframes are a bad idea - but this JavaScript solution has all of those problems too - but with worse browser support!

    And did you read the list of supported browsers? Only notable omission in the real world was safari...

    I would really love it if it weren't so - but not everybody upgrades to the latest and greatest version of their browser. Some people still use Netscape 4. (And Safari was on the list).

  • by phutureboy ( 70690 ) on Monday January 24, 2005 @11:40AM (#11455790)
    Hell, check out Oddpost [oddpost.com]
  • by dioscaido ( 541037 ) on Monday January 24, 2005 @12:13PM (#11456189)
    Is this different from script callbacks in ASP.NET? It allows you to hit the server on an already loaded page and selectively update its contents. While the full abstracted implementation will be available in ASP.NET 2.0, you can easily implement it in the current ASP.NET 1.x.

    http://msdn.microsoft.com/msdnmag/issues/04/08/Cut tingEdge/ [microsoft.com]
  • Re:Pros and cons? (Score:2, Interesting)

    by downwa ( 1083 ) on Monday January 24, 2005 @12:53PM (#11456719) Homepage
    I had seen this a few months ago, and had put together a system using a java-based JScript implementation on the server, so JSON could be evaluated both ways. It was pretty slick, being able to write a web app in entirely JScript (which is a pretty powerful language once you get to know it, naysayers notwithstanding). I had a generalized JScript library loaded client side which could produce menus and set form values from the server automatically.

    On the other hand, if your page is mostly data which will be changing (e.g. a database-backed web form), the vaunted performance isn't that much better than just slimming your HTML using CSS. And if you just use simple HTML (with CSS), you can have something which also works on lynx or older browsers, while still looking sharp on Firefox/IE/Safari/Opera/etc.
  • by chris_mahan ( 256577 ) <chris.mahan@gmail.com> on Monday January 24, 2005 @02:39PM (#11458218) Homepage
    One solution i have come up with that works ok is this:
    *use xhtml only
    *use extremely light html (under 10k if I can help it)
    *no graphics
    *no fancy nothing
    *javascript sparingly (and yes I use xml-rpc to do no-refresh data submits) (Apple, fix Safari's DomParser stuff. See http://developer.apple.com/internet/safari/safari_ faq.html#anchor19 [apple.com].)

    As far as server technology, remember to load the minimum (files, class libs, etc), optimize db queries, split pages logically for the USER, pool db connections, and return the page in 0.4 seconds (my intranet pages average .4, with .3 as common)

    And yes, I do do this for a living.

    Last but not least: do not, I repeat, do not write code that depends on IE. I'm not saying Firefox or Opera are taking over, I'm saying IE7 on Longhorn will break just enough of your IE 5.01 apps to propel you into howling fits of deranged rage.

He has not acquired a fortune; the fortune has acquired him. -- Bion

Working...