代码之家  ›  专栏  ›  技术社区  ›  Alisson Gomes

Camel rest JSON使用START_数组反序列化

  •  0
  • Alisson Gomes  · 技术社区  · 6 年前

    application/json 但我不能

    Event 在里面 camel:put

    <dataFormats>
      <json id="eventJsonList" prettyPrint="true" library="Jackson" useList="true"
        unmarshalTypeName="example.model.Event" />
    </dataFormats>
    
    <camel:rest path="events" consumes="application/json" produces="application/json">
      <camel:put 
        uri="/save">
        <to uri="direct:save-events" />
      </camel:put>
    </camel:rest>
    

    使用 Camel 2.22

    2 回复  |  直到 6 年前
        1
  •  0
  •   pcoates    6 年前

    我认为你需要使用 camel:unmarshall 告诉路线使用您的数据格式。

    <camel:rest path="events" consumes="application/json" produces="application/json">
        <camel:put uri="/save">
            <camel:route>
                <camel:unmarshal ref="eventJsonList" />
                <camel:to uri="direct:save-events" />
            </camel:route>
        </camel:put>
    </camel:rest>
    
        2
  •  0
  •   Alisson Gomes    6 年前

    所有物 bindingMode="off"

    <dataFormats>
      <json id="eventJsonList" prettyPrint="true" library="Jackson" useList="true"
        unmarshalTypeName="example.model.Event" />
    </dataFormats>
    
    <camel:rest path="events" bindingMode="off" consumes="application/json" produces="application/json">
      <camel:put 
        uri="/save">
        <to uri="direct:save-events" />
      </camel:put>
    </camel:rest>
    
    <camel:route  id="save-events">
      <from uri="direct:save-events" />
      <camel:convertBodyTo type="java.lang.String"/>
      <camel:unmarshal ref="eventJsonList"/>
      <to uri="mock:result"/>
    </camel:route>