sandesharma Absent Member.
Absent Member.
417 views

REST Driver - Handle Multiple Records in JSON

Hi,

We are using the REST driver to poll the webserivce of the HRMS system. On HTTP GET, the webserivce returns the user details in the JSON format. The format returned by the webservice is as follows:
[
{
"userid":123,
"first name":john
},
{
"userid":"1234",
"first name":"Michael"
}
]

The driver treats this as single records however, in reality they are two. How do i make the driver process these records separately?
Labels (1)
0 Likes
5 Replies
Knowledge Partner
Knowledge Partner

Re: REST Driver - Handle Multiple Records in JSON

On 3/26/2019 5:36 AM, sandesharma wrote:
>
> Hi,
>
> We are using the REST driver to poll the webserivce of the HRMS system.
> On HTTP GET, the webserivce returns the user details in the JSON format.
> The format returned by the webservice is as follows:
> [
> {
> "userid":123,
> "first name":john
> },
> {
> "userid":"1234",
> "first name":"Michael"
> }
> ]
>
> The driver treats this as single records however, in reality they are
> two. How do i make the driver process these records separately?


So the REST driver uses a JS function (You can find it in the ECMA
object in the driver) to convert JSON to XML. Actually I cannot recall
now if it is a JAva class they include or ECMA. Regardless.

If it ain't cutting it, cut your own. 🙂

There is an ITP policy that calls the ECMA, and I am too lazy to look it
up, you can do that. Disable that policy, or fix it.



0 Likes
Knowledge Partner
Knowledge Partner

Re: REST Driver - Handle Multiple Records in JSON

geoffc;2497404 wrote:
On 3/26/2019 5:36 AM, sandesharma wrote:
>
> Hi,
>
> We are using the REST driver to poll the webserivce of the HRMS system.
> On HTTP GET, the webserivce returns the user details in the JSON format.
> The format returned by the webservice is as follows:
> [
> {
> "userid":123,
> "first name":john
> },
> {
> "userid":"1234",
> "first name":"Michael"
> }
> ]
>
> The driver treats this as single records however, in reality they are
> two. How do i make the driver process these records separately?


So the REST driver uses a JS function (You can find it in the ECMA
object in the driver) to convert JSON to XML. Actually I cannot recall
now if it is a JAva class they include or ECMA. Regardless.

If it ain't cutting it, cut your own. 🙂

There is an ITP policy that calls the ECMA, and I am too lazy to look it
up, you can do that. Disable that policy, or fix it.


Is it in ECMAscript now? It used to be hidden in a Java jar file called by policy to translate JSON to XDS (and XDS to JSON) that assumed a lot of things that may not be true in all implementations.
0 Likes
Knowledge Partner
Knowledge Partner

Re: REST Driver - Handle Multiple Records in JSON

On 3/27/2019 4:24 PM, dgersic wrote:
>
> geoffc;2497404 Wrote:
>> On 3/26/2019 5:36 AM, sandesharma wrote:
>>>
>>> Hi,
>>>
>>> We are using the REST driver to poll the webserivce of the HRMS

>> system.
>>> On HTTP GET, the webserivce returns the user details in the JSON

>> format.
>>> The format returned by the webservice is as follows:
>>> [
>>> {
>>> "userid":123,
>>> "first name":john
>>> },
>>> {
>>> "userid":"1234",
>>> "first name":"Michael"
>>> }
>>> ]
>>>
>>> The driver treats this as single records however, in reality they are
>>> two. How do i make the driver process these records separately?

>>
>> So the REST driver uses a JS function (You can find it in the ECMA
>> object in the driver) to convert JSON to XML. Actually I cannot recall
>> now if it is a JAva class they include or ECMA. Regardless.
>>
>> If it ain't cutting it, cut your own. 🙂
>>
>> There is an ITP policy that calls the ECMA, and I am too lazy to look
>> it
>> up, you can do that. Disable that policy, or fix it.

>
> Is it in ECMAscript now? It used to be hidden in a Java jar file called
> by policy to translate JSON to XDS (and XDS to JSON) that assumed a lot
> of things that may not be true in all implementations.


Ya, I think I was mis-rmembering the ECMA part. I would personally do it
in ECMA not Java, mostly because then it is exposed and easier to modify.



0 Likes
Knowledge Partner
Knowledge Partner

Re: REST Driver - Handle Multiple Records in JSON

geoffc;2497469 wrote:
On 3/27/2019 4:24 PM, dgersic wrote:
>
> geoffc;2497404 Wrote:
>> On 3/26/2019 5:36 AM, sandesharma wrote:
>>>
>>> Hi,
>>>
>>> We are using the REST driver to poll the webserivce of the HRMS

>> system.
>>> On HTTP GET, the webserivce returns the user details in the JSON

>> format.
>>> The format returned by the webservice is as follows:
>>> [
>>> {
>>> "userid":123,
>>> "first name":john
>>> },
>>> {
>>> "userid":"1234",
>>> "first name":"Michael"
>>> }
>>> ]
>>>
>>> The driver treats this as single records however, in reality they are
>>> two. How do i make the driver process these records separately?

>>
>> So the REST driver uses a JS function (You can find it in the ECMA
>> object in the driver) to convert JSON to XML. Actually I cannot recall
>> now if it is a JAva class they include or ECMA. Regardless.
>>
>> If it ain't cutting it, cut your own. 🙂
>>
>> There is an ITP policy that calls the ECMA, and I am too lazy to look
>> it
>> up, you can do that. Disable that policy, or fix it.

>
> Is it in ECMAscript now? It used to be hidden in a Java jar file called
> by policy to translate JSON to XDS (and XDS to JSON) that assumed a lot
> of things that may not be true in all implementations.


Ya, I think I was mis-rmembering the ECMA part. I would personally do it
in ECMA not Java, mostly because then it is exposed and easier to modify.


Here's the fun I remember having with Java parsing of JSON and XDS.

https://forums.novell.com/showthread.php/496941-Hacking-the-JSON-produced-by-the-REST-driver-Output-Transform?highlight=gersic+json+xds

As far as I know, it's still undocumented and inflexible, but I haven't looked at it lately. Best bet, bypass their parsing and roll your own in ECMAscript.
0 Likes
Knowledge Partner
Knowledge Partner

Re: REST Driver - Handle Multiple Records in JSON

dgersic;2497472 wrote:
Here's the fun I remember having with Java parsing of JSON and XDS.

https://forums.novell.com/showthread.php/496941-Hacking-the-JSON-produced-by-the-REST-driver-Output-Transform?highlight=gersic+json+xds

As far as I know, it's still undocumented and inflexible, but I haven't looked at it lately. Best bet, bypass their parsing and roll your own in ECMAscript.


I can recommend to check JSON related library from our good friend Fernando:
Easier JSON processing IDM driver policies
https://www.netiq.com/communities/cool-solutions/cool_tools/easier-json-processing-idm-driver-policies/
https://github.com/fchierad/IDM-ECMAlib
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.