In my mule flow I have an LDAP Paged Result Search as below. I want to get the output in json. I am getting back an ArrayList.
<flow name="ldapsearchFlow1" doc:name="ldapsearchFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="3555" doc:name="HTTP"/>
<ldap:paged-result-search config-ref="LDAP" baseDn="${xxx.ad.base}" filter="(objectClass=*)" pageSize="100" doc:name="LDAP">
<ldap:attributes>
<ldap:attribute>uid</ldap:attribute>
<ldap:attribute>cn</ldap:attribute>
</ldap:attributes>
</ldap:paged-result-search>
<ldap:ldap-entry-to-ldif doc:name="ldap1"/>
<json:object-to-json-transformer doc:name="Object to JSON" />
</flow>
Output is as below. I also dont need count , attribute count etc.
���sr�java.util.ArrayListx����a��I�sizexp��%w��%t�W{"dn":"CN=aaronj,ou=people,dc=xxx,dc=org","attributes":{"count":1},"attributeCount":1}t�W{"dn":"CN=abbasa,ou=people,dc=xxx,dc=org","attributes":{"count":1},"attributeCount":1}t�X{"dn":"CN=abbottl,ou=people,dc=xxx,dc=org","attributes":{"count":1},"attributeCount":1}t�\{"dn":"CN=abeyrathnep,ou=people,dc=xxx,dc=org","attributes":{"count":1},"attributeCount":1}t�Z
There are two issues in your config related to the usage of
ldap-entry-to-ldif
:ldap:paged-result-search
. You need to either pick one LDAP entry from the search result (with a MEL expression transformer) or useldap:lookup
to return a single LDAP entry.String
. You then serialize this String as JSON. I think you need to pick one, either replaceldap-entry-to-ldif
withldap-entry-to-map
so it can properly be serialized to JSON or remove thejson:object-to-json-transformer
and let your flow return the LDIF representation. Because you stated that you want to remove some values from the final representation, I feel that you're more interested in the JSON representation than the LDIF one. In that case the former approach is what to do: after theldap-entry-to-map
, you could then use a MEL expression transformer to filter the keeps you don't want, prior to JSON serialize the map.