Hi Chathura,
On Thu, Jun 13, 2019 at 10:10 AM Chathura Ekanayake <[email protected]>
wrote:
> Hi Arunan,
>
> Enhancing EI JSON support is very useful. Does this change the syntax or
> introduce new syntax? If so, could you give some samples.
>
Yes, It introduces new syntax. But it will not effect existing users or the
configurations. To use the native JSON support, instead of giving XPath
expressions we need to give JSONPath expressions within "json-eval()". A
sample configuration for Iterate mediator is given below.
<iterate id="jsonIterator" preservePayload="true"
attachPath="json-eval($.placeHolder)"
expression="json-eval($.students.studentlist)">
<target>
<sequence/>
</target>
</iterate>
All the JSONPath supported mediators currently have a similar syntax.
> Regarding the JSON schema based transformation, how does the transform
> mediator determine mappings. Do we have to specify mappings as a part of
> the config?
>
Yes, we need to give the schema to transform the payload. Currently the
user have limited control over how the XML converts to JSON. By defining a
schema (either a partial or a complete one), the user can correct the
payload as he wants. This will be highly useful when you are using XML only
mediators (like XSLT) to manipulate a JSON payload. I will elaborate more
and share some samples once we have finalised the implementation details.
Thanks & Regards,
Arunan
>
> On Fri, Jun 7, 2019 at 12:27 PM Arunan Sugunakumar <[email protected]>
> wrote:
>
>>
>> Hi all,
>>
>>
>> I am working on implementing native JSON support for Synapse mediators.
>> As part of the effort, we have to implement JSON support in all the
>> relevant mediators and currently we have implemented native JSON support to
>> Iterate, Aggregate and Enrich mediators. We have to implement it for
>> ForEach, Header, Publish Event, Rule and Call Template mediator. Other
>> mediators either already have JSON support or not relevant to handling JSON
>> payloads (eg XSLT mediator). Please see the attachment for a complete
>> analysis.
>>
>> Initially all the JSON payloads sent to the Synapse got transformed into
>> XML and all the mediators manipulated the payload as XML using XPath. This
>> approach led to some issues such as some of the original information in the
>> JSON payload was lost during the conversion. As a remedy, it was decided to
>> implement native JSON support to the mediators. The original payload exists
>> as a stream in the Message Context and the JSON supported mediators use
>> that stream to do the data manipulation and after the manipulation, the
>> stream and the SOAP envelope are updated. Currently the problem is that, to
>> handle JSON payloads natively, we can only use JSON supported mediators in
>> the mediation. If we use a non JSON supported mediator, the JSON payload in
>> the JSON stream becomes obsolete and we have to use XPath to manipulate the
>> JSON payload in the remaining mediators.
>>
>> As a solution, we can implement JSON support for all the relevant
>> mediators and minimize this problem. This solution is totally backward
>> compatible and existing users can continue to manipulate JSON payload via
>> XPath if they want. To give users more control over the payload, we are
>> also planning to introduce a new Transform mediator which will take a
>> payload and a schema as input, and it will give out a modified payload
>> according to the schema as output.
>>
>>
>> [image: Transform mediator (2).png]
>> Any suggestions or concerns are highly appreciated.
>>
>> Thanks & Regards,
>> Arunan
>>
>> --
>> *Sugunakumar Arunan*
>> Software Engineer | WSO2
>>
>> Email : [email protected]
>> Mobile : +94766016272
>> Web : http://wso2.com
>> <https://wso2.com/signature>
>>
>
--
*Sugunakumar Arunan*
Software Engineer | WSO2
Email : [email protected]
Mobile : +94766016272
Web : http://wso2.com
<https://wso2.com/signature>
_______________________________________________
Architecture mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture