-
Notifications
You must be signed in to change notification settings - Fork 306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parse list with custom TypeConverter? #60
Comments
I actually didn't even realize the library didn't support this until you pointed it out. Any suggestions on how you'd like to see this implemented? Changing the way the existing typeConverter parameter works in the case of collections seems like a bad idea, but I'm also hesitant to add another parameter just for this use case. |
Hi! Your library only allows ArraList and LinkedList, so I can't use both if my Json includes an array... Best regards |
Is there any progress on @LouisCO 's question? We also need that RealmList support too. Thanks |
As I have a deadline for the whole app, I had to overcome this. My workaround is to ignore the RealmList for LoganSquare, ignore the List for Realm and copy from RealmList to Json when it's time to send, and from list to realm when I have to save. I do this in a custom HttpMessageConverter (from Spring Framework for Android), using awesome Android Annotations library. import com.bluelinelabs.logansquare.annotation.JsonIgnore;
import io.realm.annotations.Ignore;
import static com.bluelinelabs.logansquare.annotation.JsonObject.FieldDetectionPolicy.NONPRIVATE_FIELDS_AND_ACCESSORS;
@JsonObject(fieldDetectionPolicy = NONPRIVATE_FIELDS_AND_ACCESSORS)
public class ObjectsWrapper extends RealmObject {
@JsonIgnore private RealmList<MyObject> objects;
@Ignore public List<MyObject> objectList;
public RealmList<MyObject> getObjects() {
return objects;
}
public void setActionPoints(RealmList<MyObject> objects) {
this.objects= objects;
} Hope it's useful. Let me know if it's working for you. |
@LouisCO Thanks for the answer, it is logical but seems hard to maintain. I mean, developer can forget to conversion btwn ArrayList <-> ReamList which is error prone. Until a full support, we are gonna stick to the Gson. Thanks |
Using this makes us hold a couple for each list and also makes an efficient crud operation impossible. |
If you have some time, you can fetch the library with git, edit it by adding a boolean flag |
I made this to make LoganSquare work with Realm lists: |
I'm seeing that the issue seems to be addressed on https://github.com/krzysztof-miemiec/LoganSquare . Is it possible to explain how the typeConverter is used on the fork? Thanks. |
@EricKuck any update on this? @krzysztof-miemiec could you please share the how you addressed the issue? |
My github username got changed, so gist url stopped working. I fixed the link: https://gist.github.com/krzysztof-miemiec/d6b6449b0e0e56e4a57e4ed7bc367aab @peterbetos Unfortunately I didn't address the list issue on my fork, but it allows to perform some operations after objects are created from json hierarchy and annotate getters and setters to be used instead of fields (this allows for more flexibility). |
@krzysztof-miemiec thank you very much. It seems to be working out very well so far. |
How to Implement Logansquare Custom TypeConverter class in the Inner Json object class? kindly give me a solution.. |
Hello there!
I have a custom
TypeConverter
which extendsStringBasedTypeConverter
and converts a hex string to anInteger
(it's a representation of a color).The API I'm working with can return a single color (where this custom
TypeConverter
works great) or an array of colors. I'm super new to JSON parsing, and I'd like to use this customTypeConverter
to also deserialize an array of colors, but I can't quite figure out how to do this.In summary, I can get
"#0d9ddb"
to theInteger
type, and I'm trying to get["#0d9ddb", "#00ba6e"]
to theint[]
orList<Integer>
type. Does anyone know how to achieve this?The text was updated successfully, but these errors were encountered: