Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eunjae-lee/ModelMapper
An android library to map json string to model objects automatically based on annotations.
https://github.com/eunjae-lee/ModelMapper
Last synced: 5 days ago
JSON representation
An android library to map json string to model objects automatically based on annotations.
- Host: GitHub
- URL: https://github.com/eunjae-lee/ModelMapper
- Owner: eunjae-lee
- Created: 2014-02-14T04:33:45.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2018-06-23T04:39:57.000Z (over 6 years ago)
- Last Synced: 2024-08-01T21:47:24.654Z (3 months ago)
- Language: Java
- Homepage:
- Size: 65.4 KB
- Stars: 20
- Watchers: 4
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-android - ModelMapper - An android library to map json string to model objects automatically based on annotations. (Uncategorized / Uncategorized)
README
***THIS REPOSITORY IS NO LONGER MAINTAINED.***
ModelMapper
===========ModelMapper is an Android library to help parsing JSON strings and mapping it to objects of model classes automatically.
This is your json.
```json
{
"name": "Eunjae Lee",
"noshow": false,
"albuminfo": {
"count": 10
}
}```
This is your model.
```java
class User {
String name;
@JsonProperty("noshow")
boolean noShow;
@JsonProperty("albuminfo.count")
int albumCount;
}
```And all you need to do is:
```java
User user = ModelMapper.getInstance().generate(User.class, jsonString);
```And if you're using AndroidAnnotations, it gets simpler. You just need to put an converter at rest client interface.
```java
@Rest(converters = {JsonToModelConverter.class})
public interface MyRestClient {
@Get("/...")
User getUser();
}
```It's done.
# Download
## Maven
```xml
net.eunjae.android.modelmapper
ModelMapper
1.0.6
```
## Gradle```
compile 'net.eunjae.android.modelmapper:ModelMapper:1.0.6'
```# Usage Documentation
Check out the wiki page: https://github.com/eunjae-lee/ModelMapper/wiki
# License
[MIT](http://opensource.org/licenses/mit-license.html)# Changelog
## 1.0.6 (2014/03/12)
* OnBeforeMapping has changed a little bit.
* A field with "HashMap" type is now mapped well.
* Null check## 1.0.5 (2014/03/06)
* Bugs are fixed when it can't parse json strings with unusual structure.
* Test cases are added.## 1.0.4
* Now ModelMapper just returns json string if the first argument of ModelMapper.getInstance().generate(...) is String.class.
** There was a bug that it returned an empty string in that case.## 1.0.3
* Now this library throws exceptions when callback method(@AfterMapping) is not declared properly.
## 1.0.2
* Minor bug fix that couldn't recognize array class when it is not directly extending ArrayList.
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/eunjae-lee/modelmapper/trend.png)](https://bitdeli.com/free "Bitdeli Badge")