I'm trying to learn how to use the jackson parser to get more efficient parsing of 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 the code, I'm just trying to parse json into an array of objects:
@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 this is necessary, but here is my Category class:
@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 looks fine, no errors 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 look for this error in google, it says that there is some class in these jar files. And I donβt know how to do it ... Is there something that I am doing wrong? Or am I missing something?
Thanks in advance, any help is appreciated.
yahya
source share