json conversion issue in wso2 API Manager

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-24 13:21:03

问题


We are trying to use wso2 api manager to access some of our RESTful services. The rest services expect a json payload. When json request is sent to api manager it converts the json request to xml and again while forwarding to the actual endpoint it converts to json back. The resulting json is not matching exactly the original request in one of our cases. For instance if the rquest contains an array of elements and if only one element is passed in the array then when api manager forwards the request to the endpoint the array characters ([,]) are removed. eg. our original request was

{
    "entities": [
    {
        "name":"KK71CP20000523A1",
        "descr":"VaS",
        "mnf":"BCT",
        "mdlyr":"2012"
    }
    ]
}

the request sent by api manager was

{
    "entities": 
    {
        "name":"KK71CP20000523A1",
        "descr":"VaS",
        "mnf":"BCT",
        "mdlyr":"2012"
    }

}

The array wrapping is removed under entities element. When the number of elements is more than one then the array characters are retained.

We faced the same issue in ESB as well previously. But we worked around the issue by extending the default JSONMessageFormatter and using the seriliazeAsArray method available in the jettison library. But we dont want to do this customization in API Manager. Is there a better way of fixing this issue? Any patch available from wso2 to fix this?


回答1:


All carbon products comes with same message builders and formatters, for your case can you check with JSONStreambuilder and formatter. Look at this reference,



来源:https://stackoverflow.com/questions/16732828/json-conversion-issue-in-wso2-api-manager

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!