Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
EL-friendly
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Per Lindberg  
View profile  
 More options Apr 3 2012, 5:20 am
From: Per Lindberg <per.lindberg.4...@gmail.com>
Date: Tue, 3 Apr 2012 02:20:06 -0700 (PDT)
Local: Tues, Apr 3 2012 5:20 am
Subject: EL-friendly
I have been using the old simple JSONobject package where an object
extends HashMap and an array extends  ArrayList. This is highly
convenient in JSP because elements can be accessed directly using EL,
e.g. ${car.numberOfDoors} or ${carModels["Volvo_V70"].numberOfDoors}
or ${soldCars[4711]} . The JSP code is easy to write and read.

Now I want to switch to gson. Unfortunately, this is not possible with
gson objects, as far as I can tell.

What would be The Right Thing to fix this? It would be great if gson
JsonElement could be made EL-friendly!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Inderjeet Singh  
View profile  
 More options Apr 3 2012, 1:13 pm
From: Inderjeet Singh <inder...@gmail.com>
Date: Tue, 3 Apr 2012 10:13:09 -0700 (PDT)
Local: Tues, Apr 3 2012 1:13 pm
Subject: Re: EL-friendly
Hi Per,

Can you tell us in a bit more detail what it would take to make Gson
EL-friendly?
JsonObject already provides a few getters, those are not good enough?

Inder

On Apr 3, 2:20 am, Per Lindberg <per.lindberg.4...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Per Lindberg  
View profile  
 More options Apr 11 2012, 10:09 am
From: Per Lindberg <per.lindberg.4...@gmail.com>
Date: Wed, 11 Apr 2012 07:09:47 -0700 (PDT)
Local: Wed, Apr 11 2012 10:09 am
Subject: Re: EL-friendly
Nope, the getters are not enough. See the relevant JSRs for EL.

In short (i'm not an expert), I think that the gson JsonObject has to
imeplement Map, and JsonArray has to implement List (or perhaps
ListArray). But I'm guessing. If you have a copy of 'Head First
Servlets and JSP', turn to page 368-370. And see the relevant JSRs.

Create a JSP, add a scriptlet where you make a gson JsonObject
structure, and then try the EL access examples in my original post.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Per Lindberg  
View profile  
 More options Jan 15, 10:57 am
From: Per Lindberg <per.lindberg.4...@gmail.com>
Date: Tue, 15 Jan 2013 07:57:09 -0800 (PST)
Local: Tues, Jan 15 2013 10:57 am
Subject: Re: EL-friendly

Well. Since my suggestion hasn't been implemented, I'm now throwing out
Gson.
It has some nice features, but this deficiency renders it useless in a
JSP/JSTL environment, so any nice features become irrelevant.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Maaartin  
View profile  
 More options Jan 15, 7:41 pm
From: Maaartin <maaarti...@gmail.com>
Date: Tue, 15 Jan 2013 16:41:16 -0800 (PST)
Local: Tues, Jan 15 2013 7:41 pm
Subject: Re: EL-friendly

On Tuesday, January 15, 2013 4:57:09 PM UTC+1, Per Lindberg wrote:
> Well. Since my suggestion hasn't been implemented, I'm now throwing out
> Gson.
> It has some nice features, but this deficiency renders it useless in a
> JSP/JSTL environment, so any nice features become irrelevant.

You could
1. Create a wrapper  implementing `List` / `Map`. Not nice, but easy.
2. Create a wrapper accessing `JsonArray.elements` / `JsonObject.members`
via reflection. Even less nice (could break one day), but even easier.
3. Patch gson. This is more work as both mentioned classes already extend
`JsonElement`, so you can't use `AbstractMap` / `AbstractList`.

I wonder if there's a good reason for JsonArray/JsonObject not to implement
the interfaces.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »