데이터 파싱시 주의사항

성인석·2024년 10월 18일
0
post-thumbnail

내가 겪은 문제

Lost Ark API를 이용해 캐릭터 검색 사이트를 만드는 중, 닉네임만 다르게 했을 뿐인데 데이터가 오지 않는 문제가 발생했다.
예를 들어, "HaeSung99"라는 닉네임을 검색했을 때는 정상적으로 데이터가 출력되었지만,
"필례"라는 닉네임을 검색했을 때는 일부 데이터가 비어져서 오는 것을 확인했다.
같은 API 호출 방식을 사용했음에도 불구하고 데이터가 비어져서 오는 상황이어서 난감했다.

해결 방법

로그를 찍으면서 하나씩 확인한 결과, 요소의 번호(Element_009, Element_010 등)가 서로 다르다는 것을 발견했다.
요소들이 전부 다르게 기록되었고, 데이터를 전혀 기록하지 않는 것도 아니고 띄엄띄엄 기록된다는 것을 알게 되었다.
데이터를 가져오는 상황에서 규칙(반복문을사용하고있어서)을 정해야 했기 때문에, 두 데이터의 로그를 찍어 비교해 봤다.

HaeSung99

{
  Element_000: { type: 'NameTagBox', value: '+19 화려한 지배의 증명 장갑' },
  Element_001: {
    type: 'ItemTitle',
    value: {
      bEquip: 0,
      leftStr0: '고대 장갑',
      leftStr1: '품질',
      leftStr2: '아이템 레벨 1705 (티어 4)',
      qualityValue: 90,
      rightStr0: '장착중',
      slotData: [Object]
    }
  },
  Element_002: { type: 'SingleTextBox', value: '배틀마스터 전용' },
  Element_003: { type: 'SingleTextBox', value: '캐릭터 귀속됨' },
  Element_004: { type: 'MultiTextBox', value: '거래 불가' },
  Element_005: { type: 'SingleTextBox', value: '[상급 재련] 20단계' },
  Element_006: {
    type: 'ItemPartBox',
    value: {
      Element_000: '기본 효과',
      Element_001: '물리 방어력 +6346마법 방어력 +6346힘 +71896체력 +4654'
    }
  },
  Element_007: {
    type: 'ItemPartBox',
    value: { Element_000: '추가 효과', Element_001: '생명 활성력 +1134' }
  },
  Element_008: {
    type: 'Progress',
    value: {
      forceValue: ' ',
      maximum: 63000,
      minimum: 0,
      title: '현재 단계 재련 경험치',
      value: 0,
      valueType: 1
    }
  },
  Element_009: { type: 'IndentStringGroup', value: { Element_000: [Object] } },
  Element_010: { type: 'IndentStringGroup', value: { Element_000: [Object] } },
  Element_011: { type: 'IndentStringGroup', value: { Element_000: [Object] } },
  Element_012: {
    type: 'ItemPartBox',
    value: { Element_000: '아크 패시브 포인트 효과', Element_001: '진화 +20' }
  },
  Element_013: { type: 'SingleTextBox', value: '분해불가' },
  Element_014: { type: 'SingleTextBox', value: '[세트 업그레이드] 대도시 - 세트 장비 관리' },
  Element_015: { type: 'ShowMeTheMoney', value: '내구도 53 / 59' }
}

필례

{
  Element_000: { type: 'NameTagBox', value: '+25 화려한 환각의 미소 장갑' },
  Element_001: {
    type: 'ItemTitle',
    value: {
      bEquip: 0,
      leftStr0: '고대 장갑',
      leftStr1: '품질',
      leftStr2: '아이템 레벨 1735 (티어 4)',
      qualityValue: 100,
      rightStr0: '장착중',
      slotData: [Object]
    }
  },
  Element_002: { type: 'SingleTextBox', value: '배틀마스터 전용' },
  Element_003: { type: 'SingleTextBox', value: '캐릭터 귀속됨' },
  Element_004: { type: 'MultiTextBox', value: '거래 불가' },
  Element_005: { type: 'SingleTextBox', value: '[상급 재련] 20단계' },
  Element_006: {
    type: 'ItemPartBox',
    value: {
      Element_000: '기본 효과',
      Element_001: '물리 방어력 +7000마법 방어력 +7000힘 +87019체력 +5205'
    }
  },
  Element_007: {
    type: 'ItemPartBox',
    value: { Element_000: '추가 효과', Element_001: '생명 활성력 +1400' }
  },
  Element_008: { type: 'IndentStringGroup', value: { Element_000: [Object] } },
  Element_009: { type: 'IndentStringGroup', value: { Element_000: [Object] } },
  Element_010: { type: 'IndentStringGroup', value: { Element_000: [Object] } },
  Element_011: {
    type: 'ItemPartBox',
    value: { Element_000: '아크 패시브 포인트 효과', Element_001: '진화 +20' }
  },
  Element_012: { type: 'SingleTextBox', value: '분해불가, 품질 업그레이드 불가' },
  Element_013: { type: 'SingleTextBox', value: '[세트 업그레이드] 대도시 - 세트 장비 관리' },
  Element_014: { type: 'ShowMeTheMoney', value: '내구도 48 / 59' }
}

비교 결과, 문제는 Element_008 이후부터 발생했다.
게임의 특성을 고려하지 않았기 때문에 이러한 오류가 발생했다.
이 게임은 +25강이 마지막 강화 단계이며, 각 강화 단계마다 성장 경험치를 올려야 하지만, 마지막 단계는 성장 경험치가 필요 없기 때문에 해당 요소가 존재하지 않았다.
이로 인해 이후 요소들이 하나씩 당겨져서 기록되었음을 알게 되었다.

결론

앞으로 데이터를 파싱할 때는 주변 환경을 고려하고, 교차 비교를 통해 이러한 실수를 예방할 수 있을 것이다.

0개의 댓글