I'm trying to learn how to use jackson parser, to get more effective parsing on json data. I have these jar files: Downloaded from this page
jackson-core-2.2.0.jar
jackson-annotations-2.2.0.jar
jackson-databind-2.2.0.jar
And in code, i just try to parse a json into an objects array:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String json = ReadFromRaw(this, R.raw.json);
ArrayList<Category> categories = null;
try {
ObjectMapper mapper = new ObjectMapper();
categories = mapper.readValue(json, mapper.getTypeFactory().constructCollectionType(List.class, Category.class));
// categories = mapper.readValue(json, new TypeReference<List<Category>>() {});
} catch (Exception e) {
Log.e("MainActivity", "Error: " + e.getMessage());
}
SimpleListView myList = (SimpleListView) findViewById(R.id.myList);
myList.setAdapterWithItems(GetAdapter(categories));
}
Not sure if necessary, but here is my Category class as well:
@JsonIgnoreProperties({ "DisplayPriority" })
public class Category {
@JsonProperty("Id")
private String categoryId;
@JsonProperty("name")
private String categoryName;
public String getCategoryId() {
return categoryId;
}
public void setCategoryId(String categoryId) {
this.categoryId = categoryId;
}
public String getCategoryName() {
return categoryName;
}
public void setCategoryName(String categoryName) {
this.categoryName = categoryName;
}
}
Everything seems ok, there is no error or warnings. But when i try to compile, it gives this error:
[2013-04-25 09:32:08 - Training - JacksonParser] Error generating final archive: Found duplicate file for APK: LICENSE
Origin 1: C:\~\workspace\Training - JacksonParser\libs\jackson-core-2.2.0.jar
Origin 2: C:\~\workspace\Training - JacksonParser\libs\jackson-databind-2.2.0.jar
As i search for this error on google, it says there is some class in common on these jar files. And i do not have any idea about what to do so... Is there something that i do wrong? Or i do something missing?
Thanks in advance, any help is appreciated.