Is gson2.1.jar is compatible with Djn2.0
Hi,
We are using DJN 2.0 for implmenting ExtDirect server side stack and now it has gson1.3.jar. But, due to this old version jar, we are not able utilize several new features of Gson. Now the latest version of gson.jar is 2.2.
So, if we use gson2.2.jar with DJN, will DJN behave normally or gson2.2 is not compatible with DJN2.1.
How to use Transient keyword
Hi Pagullo,
Thank you very much for your response. I am now using DJN 2.1 and its working fine with Gson2.2.1.jar. But, now we need to obstruct some properties of the response object to be serealiazed. E.g.
Code:
@DirectMethod
public User getUser()
{
return new User();
}
User.java---
Code:
Class User
{
String userName="Jitendra";
String transient address = "Address123";
}
Now, from Gson guidelines, to obstruct "address" from being serialized to json, we have to use
Code:
GsonBuilder builder = new GsonBuilder().excludeFieldsWithModifiers(Modifier.TRANSIENT);
That means, we have to create GsonBuilder object with excludeFieldWithModifiers(). I have tried this code in the GsonBuilderConfiguratorForTesting.java in configure() method like
Code:
@Override
public void configure(GsonBuilder builder, GlobalConfiguration configuration) {
super.configure(builder, configuration);
builder.excludeFieldsWithModifiers(Modifier.TRANSIENT);
addCustomSerializationSupport(builder);
}
But, every things working fine and not any error is shown, but control does not come in callback function on clientside.
I believe, DJN is definately providing some way of configuration to implement transient attributes, but I am not finding it. Please suggest me how can i do this.
leve