XStream

JSON w/o root element

Details

  • Type: New Feature New Feature
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 1.3.1
  • Component/s: None
  • Labels:
    None

Description

Using JQuery on the browser side in conjunction with GET or POST operations, the root var name is typlically 'data'. If you serialized a simpl String through XStream with the JSON driver, you'd be given { string : "foo " } or similar.

In the JavaScript in the browser, you'd address that as ...

   alert( data.string );  

It would be nice to address it simply as ...

  alert(data);

Can we have a switch on the Json Driver : noRootNode(true); ?

Issue Links

Activity

Hide
Joerg Schaible added a comment -

Neither

"value"

nor

{ "value" }

is valid JSON.

The current JSON driver already has this no root flag (see XSTR-434), but will throw a ConversionException for a single value.

Show
Joerg Schaible added a comment - Neither
"value"
nor
{ "value" }
is valid JSON. The current JSON driver already has this no root flag (see XSTR-434), but will throw a ConversionException for a single value.
Hide
Joerg Schaible added a comment -

The new JsonWriter does support now also a mode to return simple values although it violates JSON. If created a new SNAPSHOT for your convenience.

Show
Joerg Schaible added a comment - The new JsonWriter does support now also a mode to return simple values although it violates JSON. If created a new SNAPSHOT for your convenience.
Hide
Joerg Schaible added a comment -

Set correct fix version.

Show
Joerg Schaible added a comment - Set correct fix version.
Hide
Joerg Schaible added a comment -

Fixed for upcoming release.

Show
Joerg Schaible added a comment - Fixed for upcoming release.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: