Evan Kirkconnell
unread,Jan 26, 2009, 11:37:19 AM1/26/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to json-...@googlegroups.com
Hey All,
I like this library, but it doesn't seem to support what I was hoping to first use it for. What I was wanting to do was specify a Java array, and tell it they member that should be the key values in the JSON and a different member that should be the values of the JSON.
So, basically I have this in Java:
new MyObject[]{new MyObject("key1", "val1"), new MyObject("key2", "val2")};
I'm able to produce this:
<script>
[{"key1":"val1"},{"key2":"val2"}]
</script>
using this JSP:
<json:array name="myAscObj" var="obj" items="${myObject}">
<json:object>
<json:property name="${obj.key}" value="${obj.value}"/>
</json:object>
</json:array>
but what I'd really like to get is this:
<script>
{
"key1":"val1",
"key2":"val2"
}
</script>
by doing this:
<json:array name="myAscObj" var="obj" items="${myObject}">
<json:property name="${obj.key}" value="${obj.value}"/>
</json:array>
I thought for a sec that I could get close with this, but it didn't take the variable for the object name:
<json:array name="myAscObj" var="obj" items="${myObject}">
<json:object name="${obj.key}">
<json:property name="value" value="${obj.value}"/>
</json:object>
</json:array>
So, if anyone knows another way, let me know. Otherwise, I guess it's just a request for an enhancement.
Thanks,
--Evan