orhanobut / wasp

Compact and easy to use, 'all-in-one' android network solution

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Null characters (\u0000) in strings?

DaveSanders opened this issue · comments

Using 1.15, which I think is the latest version...

I discovered that objects I was creating when pulling from my server (JSON interface) had values that did not match objects in my local device database that I was comparing to, even though the strings looked the same. One, might be: "WDI" visually, but in the value it looks like this:

"WDI\u0000\u0000\u0000\u0000\u0000\u0000" etc.

screen shot 2016-08-08 at 6 48 37 pm

Therefore the values wouldn't compare. I looked at my JSON and its correct (a snippet from PostMan):

[
  {
    "server_id": 43,
    "service_code": "WDI",
    "exact": false,

Furthermore I noticed an EMPTY string had 854,000+ characters in it.

screen shot 2016-08-08 at 6 50 39 pm

My code is relatively simple, I think... I have a method that looks like so:

@GET("/api/v1/road_orders/query?date={date}")
    void getOrders(@Path("date") String date, Callback<List<RoadOrder>> callback);

And when I call it, I'm simply doing this:

RoadApp.Connection.getOrders(yyyymmdd.format(new Date()), new Callback<List<RoadOrder>>() {
  @Override
  public void onSuccess(Response response, List<RoadOrder> roadOrders) {
    boolean oHasChanges = false;

    for(RoadOrder order:roadOrders){

So when I look at that first order in roadOrders, I notice the values - there's no other manipulation of the object before then.

Am I nuts? Is this something that Wasp is doing? How do I make it stop?

Note: this is not an issue with Wasp. I debugged it and it turns out to be buried deep in gson parser. So I'm closing this, but leaving it to be referenced by the gson "issue" I posted.