json
  • xml
  • soa
  • osb
  • 2015-11-06 201 views 2 likes 
    2

    我需要發送XML格式的JSON裏面我REST OSB 12C代理如下:在JSON字符串中是否允許換行符?

    { 
        "login": "jstein", 
        "identityContext": "jazn.com", 
        "taskId": "string", 
        "payload": { 
         "any_0": { 
          "any_01": "<afastamento xmlns:ns1='http: //www.tjsc.jus.br/soa/schemas/comagis/AfastamentoMagistrado' xsi:type='def: AfastamentoMagistradoType' xmlns:xsi='http: //www.w3.org/2001/XMLSchema-instance' xmlns='http: //xmlns.oracle.com/bpel/workflow/task'> 
          <ns1:Magistrado>719</ns1:Magistrado> 
          <ns1:Status>Inicial</ns1:Status> 
          <ns1:Vaga>8770</ns1:Vaga> 
          <ns1:Tipo>Licenca Nojo</ns1:Tipo> 
          <ns1:PeriodoReferencia/> 
          <ns1:DataInicialSolicitada>2015-10-10</ns1:DataInicialSolicitada> 
          <ns1:DataFinalSolicitada>2015-11-05</ns1:DataFinalSolicitada> 
        </afastamento>" 
         } 
        }, 
        "outcome": "Start" 
    } 
    

    的OSB 12C送我回的錯誤:

    "errorMessage" : "ORABPEL-15235\n\nTranslation Failure.\nFailed to translate 
    JSON to XML. org.codehaus.jackson.JsonParseException: Illegal unquoted 
    character ((CTRL-CHAR, code 10)): has to be escaped using backslash to be 
    included in string value\n at [Source: [email protected]; line: 
    7, column: 619]\nThe incoming data does not conform to the NXSD schema. Please correct the problem.\n" 
    

    我在JSONLint測試我的JSON請求,它總是給我的錯誤約開始的字符串與<

    Parse error on line 7: 
    "any_01": "<afastamento xmlns: 
    -----------^ 
    Expecting 'STRING, 'NUMBER, 'NULL', 'TRUE', FALSE', '{', '[' 
    
    +0

    請仔細閱讀[*我該怎麼辦時,有人回答我的問題?](http://stackoverflow.com/help/someone-answers)和[**接受**](http://meta.stackoverflow.com/q/5234/234215)答案如果你已經得到了幫助。謝謝。 – kjhughes

    回答

    4

    沒有,點燃全部擦除換行符(CTRL-CHAR, code 10)和換行是一個JSON字符串內的是not allowed控制字符:元件之間

    enter image description here

    XML不需要換行。您可以簡單地刪除它們,將多行XML文檔更改爲等效的單行XML文檔,該文檔將可以作爲JSON字符串傳遞而不會出現問題。或者,你可能要考慮逃逸以上的線路一般飼料\n,或逃避整個字符串:

    +0

    謝謝kjhughes!有了這個模式,我解決了我的問題,我們使用scaped XML –

    相關問題