How to parse JSON payloads in Dirxml script ?


NetIQ Identity manager 4.0.2 AE

I'm trying to integrate to a REST webservice from Identity manager using
a custom Http driver, since i do feel the default netiq SOAP driver is
quite complex and outdated to work with. but anyhow, I have now
established the connection between IDM and REST webservice and can
invoke http methods easily and can get back the replies. but the
replies from the webservice is based on JSON payloads. and I'm not sure
how to parse these JSON payloads easily using dirxml!!. they way i do
for SOAP based payloads using ParseXML stuff. which is quite kinda cool,
you get to work with nodesets and nodes in good way using dirxml
toolset.

Is there any thing that I can do to parse these JSON payloads using
netiq identity manager engine ( do no ask me to use Userapp).

I really do not want to read them as strings and find for the keys and
values manually feel like stupid doing this back in 80s.


I hope someone has the answer here :)

Regards,
M.


--
belaie
------------------------------------------------------------------------
belaie's Profile: https://forums.netiq.com/member.php?userid=308
View this thread: https://forums.netiq.com/showthread.php?t=53309

  • belaie wrote:

    > Is there any thing that I can do to parse these JSON payloads using
    > netiq identity manager engine ( do no ask me to use Userapp).


    I'm not aware of any direct JSON support in IDM but Ecmascript/Xpath/Java are
    an option. Lots of java JSON libraries out there e.g. minimal-json that you can
    call from XPath, either directly or via ECMA...
  • Lothar Haeger wrote:

    > Lots of java JSON libraries out there...


    Converting JSON to XML and then use XPath as usual would be another option,
    e.g. using
    http://www.json.org/javadoc/org/json/XML.html#toString(java.lang.Object)
  • "Lothar Haeger" <lothar.haeger@is4it.de> wrote:
    > Lothar Haeger wrote:
    >
    >> Lots of java JSON libraries out there...

    >
    > Converting JSON to XML and then use XPath as usual would be another option,
    > e.g. using
    > http://www.json.org/javadoc/org/json/XML.html#toString(java.lang.Object)


    Just to be clear, having worked with JSON and converting to XML that some
    endpoints expose JSON that can't be legitimately converted to XML. Things
    like JSON key (element name) beginning with a non-alpha character like $
    and also JSON value/data that can only be expressed as CDATA.

    Also some endpoints return just a plain string (not your typical JSON key -
    value pair) or even a Boolean true/false. These are valid JSON but many
    JSON to XML libraries only can handle the more common JSON structures.

    So if you go down the JSON to XML path try and find a very robust JSON to
    XML parser.

    --
    If you find this post helpful and are logged into the web interface, show
    your appreciation and click on the star below...

  • Okay.. i'm really confused now. what should I do.. is in't there any out
    of the box netiq libraries that are shipped with product to work with
    JSON payloads??..
    i'm sure i am not the only one who is working with REST webservices from
    NetIQ identity manager. there must be a solution.

    we want to poll a REST webservice and create some IDM objects based on
    the result of that webservice. so if I do plain javascript find/text
    approach i will end up with a messy code!


    --
    belaie
    ------------------------------------------------------------------------
    belaie's Profile: https://forums.netiq.com/member.php?userid=308
    View this thread: https://forums.netiq.com/showthread.php?t=53309

  • belaie wrote:

    > Okay.. i'm really confused now. what should I do.. is in't there any out
    > of the box netiq libraries that are shipped with product to work with
    > JSON payloads??..
    > i'm sure i am not the only one who is working with REST webservices from
    > NetIQ identity manager. there must be a solution.
    >
    > we want to poll a REST webservice and create some IDM objects based on
    > the result of that webservice. so if I do plain javascript find/text
    > approach i will end up with a messy code!


    Two options (at least):

    1) use a java library to convert your JSON to XML in an input transform (any
    probably back to JSON in an output transform), then continue with XML in the
    remaining driver policies

    2) use a java library to work with JSON directly in all driver policies

    In both cases you will have to

    - find a suitable library
    - copy the library jar(s) to /opt/nopvel/eDirectoty/lib/dirxml/classes
    - restart ndsd
    - (optional but stringly recommended): write ECMAscript function wrappers for
    the calls to the java library
    - call your functions from XPath

    Good Luck!

    Lothar
  • belaie wrote:

    > is in't there any out
    > of the box netiq libraries that are shipped with product to work with
    > JSON payloads??..


    Not that I am aware of. you may check the libs loaded by the engine if there's
    any JSON stuff included you can call from XPath/ECMA. There are definitely no
    DirXMLScript tokens to deal with JSON.

    > i'm sure i am not the only one who is working with REST webservices from
    > NetIQ identity manager. there must be a solution.


    Apart from the above outlined, if you have some more time to wait with this
    implementation, NetIQ is working on a REST based shim that was announced at
    Brainshare last fall and should be out "soon". Maybe you can get a more precise
    due date from your sales rep....
  • On 4/12/2015 5:29 PM, Lothar Haeger wrote:
    > Lothar Haeger wrote:
    >
    >> Lots of java JSON libraries out there...

    >
    > Converting JSON to XML and then use XPath as usual would be another option,
    > e.g. using
    > http://www.json.org/javadoc/org/json/XML.html#toString(java.lang.Object)


    On a side note. I looked at a couple of JSON Java libraries, and they
    basically were doing string manipulations, which kind of pissed me off.
    I thought that JS has some magic to handle JSON. But it was just
    doing stupid string stuff.

  • On Sun, 12 Apr 2015 20:41:48 0000, belaie wrote:

    > NetIQ Identity manager 4.0.2 AE
    >
    > I'm trying to integrate to a REST webservice from Identity manager using
    > a custom Http driver, since i do feel the default netiq SOAP driver is
    > quite complex and outdated to work with.


    Your best bet is to talk to Geoffrey. He's worked this out with a byte
    array modifier hooked in to the SOAP driver to do the bidirectional JSON/
    XML conversion you need.


    --
    --------------------------------------------------------------------------
    David Gersic dgersic_@_niu.edu
    Knowledge Partner http://forums.novell.com

    Please post questions in the forums. No support provided via email.
    If you find this post helpful, please click on the star below.
  • On 4/13/2015 11:30 AM, David Gersic wrote:
    > On Sun, 12 Apr 2015 20:41:48 0000, belaie wrote:
    >
    >> NetIQ Identity manager 4.0.2 AE
    >>
    >> I'm trying to integrate to a REST webservice from Identity manager using
    >> a custom Http driver, since i do feel the default netiq SOAP driver is
    >> quite complex and outdated to work with.

    >
    > Your best bet is to talk to Geoffrey. He's worked this out with a byte
    > array modifier hooked in to the SOAP driver to do the bidirectional JSON/
    > XML conversion you need.


    And I used a Java class I found that did the conversion from JSON to
    XML. Which is then manageable in Policy and XSLT.


  • Geoffrey Carman <geoffreycarmanNOSPAM@NOSPAMgmail.com> wrote:

    > And I used a Java class I found that did the conversion from JSON to XML.
    > Which is then manageable in Policy and XSLT.


    I've also tweaked this Java class from Geoffrey to handle problematic JSON
    / XML conversion scenarios as I described yesterday. However the original
    poster said they did not want to use the SOAP driver for this.

    My advice to original poster.

    If you can't wait for REST driver from netiq, then use SOAP Geoffrey's
    byteArrayModifier Java class. Works fine.

    I don't know if any public netiq Java classes which can do the JSON to xml
    roundtrip conversion, so you need to rely on a third party class or write
    your own.

    --
    If you find this post helpful and are logged into the web interface, show
    your appreciation and click on the star below...