Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Convert POJO -> JSON in rap 2.0 (Parameter object can not be converted to JSON value)
Convert POJO -> JSON in rap 2.0 [message #1038259] Wed, 10 April 2013 16:28 Go to next message
Anatoliy Pogorelov is currently offline Anatoliy Pogorelov
Messages: 10
Registered: April 2013
Junior Member
Hi, in my rap 2.0 used custom widget.

RemoteObject remoteClientObject;
private MyJson myJson = new MyJson();
Connection connection = RWT.getUISession().getConnection();
remoteClientObject = connection.createRemoteObject("rap.MyObject");
remoteClientObject.set("parent", WidgetUtil.getId(this));
remoteClientObject.set("text", "myText");
remoteClientObject.set("datee", myJson);

and when custom widget is opened we have error
Parameter object can not be converted to JSON value: xxx.MyJson@73986b

without remoteClientObject.set("datee", myJson) it's work correctly

MyJson:
class MyJson implements Serializable{

private static final long serialVersionUID = 2769033938543409463L;

public MyJson() {}

private int foo;

public void setFoo(int foo) {
this.foo = foo;
}

public int getFoo() {
return foo;
}

}

Please, where is problem?
Thanks, Anatoliy
Re: Convert POJO -> JSON in rap 2.0 [message #1038697 is a reply to message #1038259] Thu, 11 April 2013 07:34 Go to previous messageGo to next message
Ralf Sternberg is currently offline Ralf Sternberg
Messages: 1291
Registered: July 2009
Senior Member

Hi Anatoliy,

we'll provide a method to priovide your own JSON to a RemoteObject in
RAP 2.1. In RAP 2.0, you can only provide Strings, ints, etc. So in your
case you should use:

remoteClientObject.set( "datee", myJson.getFoo() );

Regards, Ralf

--
Ralf Sternberg

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Convert POJO -> JSON in rap 2.0 [message #1038939 is a reply to message #1038697] Thu, 11 April 2013 14:26 Go to previous messageGo to next message
Ralf Sternberg is currently offline Ralf Sternberg
Messages: 1291
Registered: July 2009
Senior Member

I've opened bug 405474 [1] for custom JSON support in RemoteObject and
OperationHandler.

Regards, Ralf

[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=405474

--
Ralf Sternberg

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Convert POJO -> JSON in rap 2.0 [message #1039634 is a reply to message #1038259] Fri, 12 April 2013 11:38 Go to previous message
Anatoliy Pogorelov is currently offline Anatoliy Pogorelov
Messages: 10
Registered: April 2013
Junior Member
Thanks, Ralf!
Previous Topic:Cannot deploy to Tomcat 7
Next Topic:Missing Constraint: Import-Package: javax.servlet; version="2.6.0
Goto Forum:
  


Current Time: Fri Oct 24 15:00:31 GMT 2014

Powered by FUDForum. Page generated in 0.01632 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software