Hi Aditya, You can use XSLT mediator to achieve this, following is a sample configuration I created.
<?xml version="1.0" encoding="UTF-8"?> > <proxy xmlns="http://ws.apache.org/ns/synapse" > name="sample" > startOnLoad="true" > statistics="disable" > trace="disable" > transports="http,https"> > <target> > <inSequence> > <property name="messageType" scope="axis2" > value="application/json"/> > <xslt key="transform"/> > <respond/> > </inSequence> > </target> > <description/> > </proxy> <localEntry key="transform"> > <xsl:stylesheet version="1.0" xmlns:xsl=" > http://www.w3.org/1999/XSL/Transform"> > <xsl:template match="/"> > <Childern> > <xsl:for-each select="//Children"> > <xsl:element name="{Name/Value}"> > <xsl:value-of select="Education/Value"/> > </xsl:element> > </xsl:for-each> > </Childern> > </xsl:template> > </xsl:stylesheet> > <description/> > </localEntry> Input will be following, > { > "Children": [ > { > "Name": { > "Type": "System.String", > "Value": "Gayle" > }, > "Education":{ > "Type": "System.String", > "Value": "PostGraduate" > } > }, > { > "Name": { > "Type": "System.String", > "Value": "Chris" > }, > "Education":{ > "Type": "System.String", > "Value": "Graduate" > } > }, > { > "Name": { > "Type": "System.String", > "Value": "Steve" > }, > "Education":{ > "Type": "System.String", > "Value": "PostGraduate" > } > }, > { > "Name": { > "Type": "System.String", > "Value": "Stephen" > }, > "Education":{ > "Type": "System.String", > "Value": "Graduate" > } > } > ] > } Output: { > "Childern": { > "Gayle": "PostGraduate", > "Chris": "Graduate", > "Steve": "PostGraduate", > "Stephen": "Graduate" > } > } Thanks, On Sun, Jan 7, 2018 at 6:23 PM, aditya shivankar < shivankar.adit...@gmail.com> wrote: > Respected Sir, > > I have response from one external service something like below, indicating > children name and education. > Each time i call this service with different input, it returns me few > children( number of children returned could be different each time > depending on my request data ). > > > Service Response(which needs to be transformed) > { > "Children": [ > { > "Name": { > "Type": "System.String", > "Value": "Gayle" > }, > "Education":{ > "Type": "System.String", > "Value": "PostGraduate" > } > }, > { > "Name": { > "Type": "System.String", > "Value": "Chris" > }, > "Education":{ > "Type": "System.String", > "Value": "Graduate" > } > }, > { > "Name": { > "Type": "System.String", > "Value": "Steve" > }, > "Education":{ > "Type": "System.String", > "Value": "PostGraduate" > } > }, > { > "Name": { > "Type": "System.String", > "Value": "Stephen" > }, > "Education":{ > "Type": "System.String", > "Value": "Graduate" > } > } > ] > } > > > Desired Output : > > { > "Gayle": "PostGraduate", > "Chris": "Graduate", > "Steve": "PostGraduate", > "Stephen": "Graduate" > } > > I would like to do this using PayloadFactory or Enrich component. > I cannot use dataMapper,because the actual response from service is too > big and dataMapper GUI hangs and also makes eclipsce to hang forever for > such big jsons. > Please guide. > > With Regards, > Aditya > > _______________________________________________ > Dev mailing list > Dev@wso2.org > http://wso2.org/cgi-bin/mailman/listinfo/dev > > -- *Eranda Rajapakshe* Software Engineer WSO2 Inc. Mobile : +94784822608
_______________________________________________ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev