본문으로 건너뛰기
SDETRole
SDETRole

JSON·데이터

JSONPath 테스터

실제 JSON에 JSONPath 표현식을 실행해 모든 매치와 경로를 확인합니다.

브라우저에서만 실행됩니다 회원가입 불필요

JSON document

0 chars

Result

Paste JSON or load the sample, then type an expression

Results update as you type. Filter expressions are evaluated by a safe interpreter, never with eval.

Syntax cheatsheet

ExpressionMeaningAction
$Root of the document
$.store.bicycleChild by name (dot notation)
$['store']['book']Child by name (bracket notation, for keys with spaces or dashes)
$..authorRecursive descent: every "author" at any depth
$.store.*Wildcard: all children
$.store.book[0]Array index (0-based)
$.store.book[-1:]Last element (slice)
$.store.book[0,2]Union of indexes
$.store.book[1:3]Slice: index 1 up to (not including) 3
$.store.book[?(@.price < 10)]Filter: elements matching a condition
$..book[?(@.isbn)]Filter: elements that have a truthy "isbn"
$..book[?(@.category == 'fiction' && @.price > 10)]Combined conditions with && and ||
$.store.*~Property names instead of values (jsonpath-plus extension)

Filters support @ and $ references, strings, numbers, true/false/null, == != < <= > >=, &&, || and !. Script expressions such as [(@.length-1)] and function calls are not executed.

도구 소개

JSONPath는 대부분의 API 테스트 프레임워크가 응답에서 값을 꺼내는 방식입니다. REST Assured의 JsonPath, Postman 스크립트, Karate, 여러 어설션 라이브러리가 같은 개념을 사용합니다. 실제 응답에 대고 표현식을 작성하면 실패하는 테스트 실행을 한 번 줄일 수 있습니다. 이 테스터는 스크립트 평가를 끈 jsonpath-plus를 사용하고, [?(@.price < 10)] 같은 필터 표현식은 작은 내장 인터프리터로 평가하므로 붙여 넣은 내용이 코드로 실행되는 일은 없습니다. 모든 매치는 정규화된 경로와 함께 표시되어 값이 정확히 어디에서 왔는지 알 수 있습니다.

사용 방법

  1. 왼쪽 패널에 JSON 응답을 붙여 넣거나 “Load sample”(샘플 불러오기)로 고전적인 서점(bookstore) 문서를 불러오세요.
  2. $로 시작하는 표현식을 입력하세요. 입력하는 동안 결과가 갱신됩니다.
  3. 값, 경로 또는 둘 다 표시할지 고른 다음 결과를 복사하세요.
  4. 치트시트의 “Try” 버튼으로 재귀 탐색, 슬라이스, 유니언, 필터가 동작하는 모습을 확인하세요.

JSONPath 테스터 자주 묻는 질문

여기서는 되는 표현식이 왜 REST Assured에서는 안 되나요?

REST Assured는 Goessner JSONPath가 아니라 Groovy GPath를 사용합니다. GPath의 “store.book.findAll { it.price < 10 }.title”은 여기서의 “$.store.book[?(@.price < 10)].title”과 같습니다. 단순한 점 경로는 둘 다 같지만 필터와 와일드카드 문법은 다릅니다.

어떤 필터 문법을 지원하나요?

필터는 현재 항목(@)이나 루트($)를 참조할 수 있고, == != < <= > >=로 비교하며, && || !로 조합하고, 문자열, 숫자, true, false, null을 사용할 수 있습니다. [(@.length-1)] 같은 스크립트 표현식과 JavaScript 메서드 호출은 의도적으로 실행하지 않습니다. 마지막 요소에는 슬라이스 [-1:]을 사용하세요.

키가 있는데도 왜 매치가 없나요?

흔한 원인은 대소문자 차이(userId와 userid), 값이 배열 안에 있는데 [*]를 빠뜨린 경우, 또는 $['first-name']처럼 대괄호 표기법이 필요한 대시나 공백이 포함된 키입니다.

SDETRole 전체에서 검색할 내용을 입력하세요.

Pagefind 전문 검색 · 브라우저에서 실행됩니다 검색 페이지 열기 →