Details
Description
I want to use a resulting JSON formatted XStreamed object in a browser
in JS.
The way JSON libraries typically works are to push the resulting
object into a closure :
function (data) {
// do something with data. like .....
alert(data.field1)
}
Well that would be the case, but for objects that come from the two
JSON capable drivers in XStream, they are doing to look more like
function (data) {
alert(data.rootNode.field1)
}
'data' is prepended by the JSON libraries. rootNode (more typically
the Java type name of the root node) is made by XStream.
Could we have a mode of operation for the two JSON types that allowed
for "no root node" ? Like so ..
{"name" : "Fred", "sex" : "Male"}
instead of ..
{"MyPerson":
{"name" : "Fred", "sex" : "Male"}}
Issue Links
- is duplicated by
-
XSTR-535 JSON w/o root element
As an option, this is not needed. It should be like this all the time.
Patch supplied. It works perfectly, but you could judge it to be a bit hacky. There's some schenanigans to ensure there is always an opening brace.