4
如何将以下json字符串转换为java对象?
我想将以下JSON字符串转换为Java对象: String jsonString = "{ "libraryname":"My Library", "mymusic":[{"Artist Name":"Aaron","Song Name":"Beautiful"}, {"Artist Name":"Britney","Song Name":"Oops I did It Again"}, {"Artist Name":"Britney","Song Name":"Stronger"}]}" 我的目标是轻松访问它,例如: (e.g. MyJsonObject myobj = new MyJsonObject(jsonString) myobj.mymusic[0].id would give me the ID, myobj.libraryname gives me "My Library"). 我听说过杰克逊,但是由于涉及“ mymusic”列表,我不知道如何使用它来适应我拥有的json字符串,因为它不仅仅是键值对。如果杰克逊不是最好的选择,我该如何用杰克逊完成?