자바에서 임의의 클래스를 중첩 TMP => { "RESULT_COUNT"1 "next_offset"1 "entry_list": [{ "ID": " "name": "name": "name": "xyz123", "module_name": "제품", "name_value_list" "값": "test_product_2"}}}] "relationship_list"직렬화 내가 JSON 문자열을 변환해야 GSON
내 POJO는
public class GetEntryListResponse {
public int result_count = 0;
public int next_offset = 0;
public List<EntryList> entryList = new ArrayList<EntryList>();
public static class EntryList {
String id = "";
String module_name = "";
public static class NameValueList {
public static class Id {
String name = "";
String value = "";
}
public static class Name {
String name = "";
String value = "";
}
}
}
}
같은과 deserilizing 태스크 A에 대해 보이는 해당 자바 POJO로 []} 사용하다
Gson json_response = new Gson();
GetEntryListResponse resp = json_response.fromJson(tmp,
GetEntryListResponse.class);
다른 변형도 시도했지만이 중 가장 좋은 것으로 보입니다. 문제는 result_count 및 next_offset이 int로 변환되지만 entryList 배열의 유형이 null 값을 갖는 것입니다.
당신은 스타일을 혼합하고 있습니다 :'result_count'와'entryList'는 함께 괜찮을 수 있습니다 (Json에서 같은 혼돈을 사용하지 않는다면). 'FieldNamingStrategy'를 사용하여 당신을 볼 수 없기 때문에 어떻게 작동 할 수 있는지 궁금합니다. – maaartinus