188장. JsonPath Language

Camel 버전 2.13에서 사용 가능

Camel은 json 메시지에 Expression 또는 Predicate를 사용할 수 있도록 JSonPath 를 지원합니다.

from("queue:books.new")
  .choice()
    .when().jsonpath("$.store.book[?(@.price < 10)]")
      .to("jms:queue:book.cheap")
    .when().jsonpath("$.store.book[?(@.price < 30)]")
      .to("jms:queue:book.average")
    .otherwise()
      .to("jms:queue:book.expensive")

188.1. JSonPath Options

JsonPath 언어는 아래 나열된 7 가지 옵션을 지원합니다.

이름기본값Java Type설명

resultType

 

문자열

결과 형식의 클래스 이름을 설정합니다(출력에서 유형)

suppressExceptions

false

부울

PathNotFoundException과 같은 예외를 억제할지 여부입니다.

allowSimple

true

부울

JsonPath 표현식에서 인라인으로 간단한 예외를 허용할지 여부

allowEasyPredicate

true

부울

쉬운 서술자 구문 분석기를 사용하여 사전 분리 서술자를 사용할 수 있는지 여부입니다.

writeAsString

false

부울

Map/POJO 값 대신 각 row/element의 출력을 JSON String 값으로 작성할지 여부입니다.

headerName

 

문자열

메시지 본문 대신 입력으로 사용할 헤더 이름

trim

true

부울

선행 공백과 후행 공백과 줄 바꿈을 제거할 값을 조정할지 여부입니다.