LoganSquare parsing Android library : feedback, benchmarks, pros, cons
Asked Answered
G

4

16

I'm using Jackson with DataBind library to parse json and map it java object. I'm also using Gson on other project where perf is less required.

On 17 Feb, LoganSquare library is first released, promising 4-10 time faster parsing as Gson.

  • What advantages as LoganSquare than Gson/Jackson didn't have ?
  • Pros and cons ?
  • Do you have benchmarks in production application ?
  • Is is stable enough for a production app?

I understand it can be a primarly opinion base question, so be as technic and specific as possible and base your answer on real data.

Gav answered 22/6, 2015 at 13:44 Comment(2)
you have all answers in first paragraph of README.mdPablo
I wanted to have informations about other developers that those who are developping it. @PabloGav
H
19

Well to be clear if you are releasing your app to devices with ART you will have a huge speed advantage trough parsing.

so i will explain my experience with logansquare so far.

pros :

  • Easy to use: with Gson you have to use Type for parsing json array to a object list, in loganSquare it is so easy as LoganSquare.parseList()
  • Faster : in any device (test it yourself) it is slightly faster.
  • FasterER: in ART devices its speed gap is really giant see their benchmark
  • RetroFit friendly: yeah it plays well with retrofit.

cons :

  • NO REALM DB : I could't make it run with Realm db so far(I didnt tried hard yet)

  • Custom Type Adapter :Couldn't find a type adapter or something similar so far but I am not sure.

see their benchmark here

and here is my poor benchmark results(it is not a proper benchmark but it is something): Emulator nexus 5, with DalvikVM,4.2 jellybean

Benchmarks

parsing time sheet

parsing time graph

Parsed model

import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import com.google.gson.annotations.SerializedName;

/**
 * Created by Ercan on 6/26/2015.
 */
@JsonObject(serializeNullCollectionElements = true ,serializeNullObjects = true)
public class Village {

    @SerializedName("IdVillage")
    @JsonField(name ="IdVillage")
    String tbsVillageId;

    @SerializedName("TBS_VillageId")
    @JsonField(name ="TBS_VillageId")
    String townRefId;

    @SerializedName("VillageName")
    @JsonField(name ="VillageName")
    String villageName;

    @SerializedName("Status")
    @JsonField(name ="Status")
    String status;

    @SerializedName("DateInserted")
    @JsonField(name ="DateInserted")
    String dateInserted;

    @SerializedName("DateLastModified")
    @JsonField(name ="DateLastModified")
    String datelastModified;

    public String getTbsVillageId() {
        return tbsVillageId;
    }

    public void setTbsVillageId(String tbsVillageId) {
        this.tbsVillageId = tbsVillageId;
    }

    public String getTownRefId() {
        return townRefId;
    }

    public void setTownRefId(String townRefId) {
        this.townRefId = townRefId;
    }

    public String getVillageName() {
        return villageName;
    }

    public void setVillageName(String villageName) {
        this.villageName = villageName;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getDateInserted() {
        return dateInserted;
    }

    public void setDateInserted(String dateInserted) {
        this.dateInserted = dateInserted;
    }

    public String getDatelastModified() {
        return datelastModified;
    }

    public void setDatelastModified(String datelastModified) {
        this.datelastModified = datelastModified;
    }
}
Haha answered 10/8, 2015 at 6:47 Comment(0)
W
4

I have run LoganSquare Benchmark project on my Nexus 5 device with Android 6.0.1 and here is the result:

LoganSquare Benchmark screenshots

Also, after a short time spend with the lib, here are my pros and cons:

Pros

  1. is really fast in both parsing and serialization
  2. small library size
  3. handy methods for lists parsing and serialization
  4. useful converters
  5. compile-time errors instead of run-time only

Cons

  1. not much of a documentation, also not many questions & answers on StackOverflow :)
  2. not many types supported
  3. only String keys supported in Map collections

I wrote an example project to see how LoganSquare works and also a blog post, so take a look there for more information.

Whitten answered 1/6, 2016 at 19:5 Comment(0)
B
2

response.body() it is string json response

// MovieData it is a model Class

 MovieData movieData=LoganSquare.parse(response.body(),MovieData.class);

 Log.d("onResponse: ",movieData.getTitle());
Babineaux answered 20/2, 2019 at 11:20 Comment(1)
This doesn't really answer the question asked.Hearthstone
C
1

The library is not updated since 4+ years.

It was working mostly fine till now but according to my knowledge it will stop working after gradle 5.

Clamp answered 3/9, 2019 at 10:58 Comment(1)
what makes you say that? Please provide links to back your claims.Niemi

© 2022 - 2024 — McMap. All rights reserved.