bluelinelabs / bluelinelabs/LoganSquare
Configure parsing of collections
- Dominant language
- Java
- Stars
- 3.2k
- Forks
- 303
- PR merge metrics
- No merged PRs in 30d
Description
Twitter uses LoganSquare heavily to generate model objects from Json. In particular, we use type converters to avoid the need for copying lists when converting them to model objects. For example:
``` java
@JsonObject
public class JsonTweet extends ModelObjectProvider {
// ...
}
@JsonObject
public class JsonTweetList extends ModelObjectProvider {
@JsonField
public List tweetList;
@Override
@NotNull
public TweetList toModelObject() {
return new TweetList(tweetList);
}
}
```
This works as expected by declaring a type converter for Tweet that uses JsonTweet. The one thing we don't have control over is the creation of the list: I would like to be able to configure LoganSquare to use my own implementation of List; in particular, I would like to be able to guarantee that all parsed lists are immutable.
More in general, I would like to have the means to declare how to parse arbitrary collections, like SparseArray or map that don't use string keys. I think this would be a valuable addition to LoganSquare. Have you considered adding this feature? What are you ideas on how this would work?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reviewing LoganSquare's type-converter handling and the ModelObjectProvider example described in the issue. Investigate how parsed List values are created, then consider the requested API for custom List implementations and arbitrary collections such as SparseArray or maps without string keys. Done would require an agreed design and implementation scope; no files or tests are named.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- api, mobile
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100