You are a developer, not a coder.

JSON Pasing Tip 본문

Backend-Languages/Java

JSON Pasing Tip

Mattmk 2020. 12. 1. 16:26
SMALL
"result" : {
  "groupeds": {
    "790": [
    {
      "index": 1,
      "rank": 1,
      "score": 0.5,
      "catId": "050",
      "itId": "633",
      "product": {}
    }
}

다음과 같이 복잡한 구조의 JSON이 있다.

배열 -> 배열 -> 리스트 형식이다.

 

이럴때에는 Map의 제네릭을 이용하여 Object 묶음으로 Pasing 했지만, 꺼내쓰는걸 잘 몰라서

한참 써칭을 하고 해결을 했다.

꺼내 쓰는 방법은 아래와 같다.

 

for (Entry<String, List<RankingVo>> entry : apiTuple.getRankingResults().entrySet()) {
	System.out.println("Cities: " + entry.getKey() + ", " + entry.getValue());
}

 

 

LIST
Comments