HI,
You can fix the second issue by enabling the property "
synapse.commons.json.output.disableAutoPrimitive.regex". Refer doc [1] for
more information.

[1] -
https://docs.wso2.com/display/EI611/JSON+Support#JSONSupport-XMLtoJSONtransformationparameters

/Vinod

On Wed, Oct 25, 2017 at 2:28 PM, aditya shivankar <
[email protected]> wrote:

> Hi,
>
> Thanks Manorama , the 2nd issue is relsoved with this.
>
> Could you please help me with 1st issue as well ?
> Or Provide some configuration like above , which will preserve the array,
> even if there is only one element in array.
>
> With Regards
> Aditya
>
>
> On Wed, Oct 25, 2017 at 12:32 PM, Manorama Perera <[email protected]>
> wrote:
>
>> Hi Aditya,
>>
>> In order to preserve the double quotations around the numbers, you can
>> configure the below property in <ESB_HOME>/repository/conf/syn
>> apse.properties
>>
>> synapse.commons.json.output.autoPrimitive=false
>>
>> Thanks,
>> Manorama
>>
>> On Wed, Oct 25, 2017 at 11:31 AM, aditya shivankar <
>> [email protected]> wrote:
>>
>>> Below is the sample service I have created to Highlight the issues I am
>>> facing in my project(where the request and response are very big and these
>>> issues are repeating at many places).
>>>
>>> Request :
>>> {
>>> "id" : "3",
>>> "parts" : ["Screen"]
>>> }
>>>
>>> Actual Response :
>>> {
>>>     "id": 3,
>>>     "parts": "Screen",
>>>     "make": "Tamsung"
>>> }
>>>
>>> Desired Response  :
>>>
>>> {
>>>     "id": "3",
>>>     "parts": ["Screen"],
>>>     "make": "Tamsung"
>>> }
>>>
>>> ------------------------------------------------------------
>>> -------------------------------------------------------
>>> Issues :
>>>
>>> 1.     "parts": "Screen",
>>>
>>>        should have been like below
>>>
>>>        "parts": ["Screen"],
>>>
>>>       i.e. it does not remain array anymore. I understand the array
>>> consist only one element. But the third party system to which the output of
>>> this service is sent as input(request) expects the element as array. So I
>>> need it to be as array.
>>>
>>> 2.    "id": 3,
>>>
>>> should have been like below
>>> "id": "3",
>>> i.e. the string should have been kept as string.
>>>
>>>
>>> ------------------------------------------------------------
>>> -------------------------------------------------------
>>> arrayTest.xml :
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <api context="/arrayTest" name="arrayTest" xmlns="
>>> http://ws.apache.org/ns/synapse";>
>>>     <resource methods="POST GET">
>>>         <inSequence>
>>>
>>>             <enrich>
>>>                 <source clone="true" type="inline">
>>>                     <make xmlns="">Tamsung</make>
>>>                 </source>
>>>                 <target action="child" xpath="//jsonObject"/>
>>>             </enrich>
>>>             <enrich>
>>>                 <source clone="true" xpath="//jsonObject"/>
>>>                 <target type="body"/>
>>>             </enrich>
>>>
>>>             <respond/>
>>>         </inSequence>
>>>         <outSequence/>
>>>         <faultSequence/>
>>>     </resource>
>>> </api>
>>>
>>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Dev mailing list
>>> [email protected]
>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>
>>>
>>
>>
>> --
>> Manorama Perera
>> Software Engineer
>> WSO2, Inc.;  http://wso2.com/
>>
>
>
> _______________________________________________
> Dev mailing list
> [email protected]
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>


-- 
Vinod Kavinda
Senior Software Engineer
*WSO2 Inc. - lean . enterprise . middleware <http://www.wso2.com>.*
Mobile : +94 (0) 712 415544
Blog : http://soatechflicks.blogspot.com/
[image: http://wso2.com/signature]
<http://wso2.com/signature>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to