json
  • xml
  • soa
  • osb
  • 2015-11-06 57 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 –

    相关问题