I have the following method which retrieves a JSON string from a remote REST API. The JSON string contains French characters. The problem is that the French text in the JSON string is mangled.
I am using the GluonConnect REST client library to fetch the JSON string from the remote server. Everything is fine except for the retrieval of JSON with non-English text.
Here is my method:
public void retrieveJsonString() {
// GluonConnect RestClient setup
RestClient restClient = RestClient.create().host(this.host).path(this.path).queryParam("schema", this.schema).queryParam("uri", "/contactsform").method("GET");
// GluonConnect GluonObservableObject setup
GluonObservableObject<String> godp = DataProvider.retrieveObject(restClient.createObjectDataReader(String.class));
// Add a listener to the GluonObservableObject
godp.stateProperty().addListener(new InvalidationListener() {
@Override
public void invalidated(Observable arg0) {
if (godp.getState().equals(ConnectState.SUCCEEDED)) {
response.bind(godp.asString());
}
}
});
}
The key line is response.bind(godp.asString()). godp.AsString() returns mangled text. For example, the word "Médiateur" with an accented é is displayed as "Médiateur". If I change the line to response.bind(godp.asString(Locale.FRANCE, null)), then nothing is returned.
Please what am I doing wrong? Thanks a lot for your kind assistance.