ranjan

Archive for November, 2009

Groovy – Producing JSON using Groovlet and JSONObject

In Geek Stuff, Groovy and Grails on November 19, 2009 at 8:09 am

Groovy – Producing JSON using Groovlet and JSONObject

All right I admit I like groovy, because it’s gives you taste of best of both worlds – all the dynamism of Python and Ruby and still be close to Java.

I was trying to create simple JSON output using Groovlets and JSONObject and this is what I came up with.

In order to use Groovlets use the this link to set it up in your favorite IDE.

And then

  1. Create index.groovy in WEB Folder.

  2. Download the source code from json.org/java site

  3. put in your src folder of web project.

  4. In your index.groovy put in this code

Here’s the code

import org.json.*;
import com.ranjan.*;

/***************************************************
*
*
Setting up response content type is
important
*
and in best practice.
****************************************************/

response.setContentType("application/json");

def fromMap =
[name:"Frederic Jean",age:32]
as JSONObject
def fromList =
["English","French","Spanish"]
as JSONArray

def newMap =
[
    world:[
        countries:[
            india:[
                cities:["delhi", "bombay"]
            ],
            america:[
                states:["new york", "chicago"]
            ],
            japan:[
                states:["tokyo","some great japanese city"]
            ]

        ]
    ]
]
as JSONObject
// this is what does the trick

println newMap

The result...


Designing an Web Interface.

In Interaction Design, Uncategorized on November 2, 2009 at 11:08 am

Lately I have started to love to think about user interface, specially web user interface. I’m not sure where I caught the bug from or how it began, but it has kept me thinking a lot lately of how to design webui.

There are lot of design sites and consultants and some of them you can find on nettuts.com or on W3CSites.com but these are again one page design and my head is filled with more of design issues we face in business software, especially communication software ( microsoft exchange sucsk ) and in particular e-commerce.

Here’s the layout I came up with, and this very basic and will be progressively enhanced later on.

Layout Design 1

There are some issues i know, like the footer still looks ugly and clueless.

By the way this is just a layout design and has no content design added as of yet, but it would be interesting to read comments and get feedback on this. Please feel free to do so.

I will publishing more enhancements later on.