[英]Are line feeds allowed in JSON strings?
我需要在REST OSB 12c代理的JSON內發送XML,如下所示:
{
"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: java.io.BufferedReader@7db921c7; 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', '{', '['
不 ,文字換行符( CTRL-CHAR, code 10
)和換行符是JSON字符串中不允許的控制字符:
XML不需要元素之間的換行符。 您只需刪除它們,即可將多行XML文檔更改為等效的單行XML文檔,該文檔將能夠毫無問題地作為JSON字符串進行傳遞。 或者,您可能要考慮對換行符\\n
轉義,或更籠統地說,對整個字符串進行轉義:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.