Topic
  • 6 replies
  • Latest Post - ‏2014-08-11T17:37:11Z by kolban
BornikChatterjee
BornikChatterjee
146 Posts

Pinned topic REST Web Service Response JSON parsing

‏2013-04-04T13:53:39Z |
Hi,

I am trying to integrate a external REST web service which is returning a JSON response. I want parse that JSON into Lombardi complex variable. I found some examples for REST web service which is returning xml but not for JSON response. Can someone help me with some examples of JSON parsing in Lombardi.

I am using IBM BPM 8.0. I tried by including Json-lib in my project. But as I am not very good in java could not figure out how to use this properly.

Example Response:

{
"results":{
"next":"prod",
"items":[{
"id":"840dr5ru-fb22b8355658494e92507ebb77826fce"
},{
"id":"840dr5ru-e62e7963b0bd44619dd0c44adf46318a"
}]
}
}

Bornik
Updated on 2013-04-04T17:39:54Z at 2013-04-04T17:39:54Z by BornikChatterjee
  • kolban
    kolban
    3322 Posts

    Re: REST Web Service Response JSON parsing

    ‏2013-04-04T15:24:18Z  
    Hi Bornik,
    "Lombardi" is a dead word to me these days :-) I think what you are asking is to parse an IBM BPM Business Object.

    In what "environment" are you making your REST calls from? Is it a browser, a Java app, a BPM Service or something else.

    Neil
  • BornikChatterjee
    BornikChatterjee
    146 Posts

    Re: REST Web Service Response JSON parsing

    ‏2013-04-04T15:52:17Z  
    • kolban
    • ‏2013-04-04T15:24:18Z
    Hi Bornik,
    "Lombardi" is a dead word to me these days :-) I think what you are asking is to parse an IBM BPM Business Object.

    In what "environment" are you making your REST calls from? Is it a browser, a Java app, a BPM Service or something else.

    Neil
    Hi Neil,

    I am trying to use this from BPM implementation service. I have the response in string format. Need to parse that to IBM BPM Business Object ("Lombardi" variable to me :))

    Also I like to add that I always read your book before searching answer of the problem from any other source. And with the help two developer works article referred by you in the book I have successfully able to call the REST web service and set the response in a string. But now I hit a roadblock to parse that response back to Lombardi object IBM BPM Business Object.

    Bornik
  • kolban
    kolban
    3322 Posts

    Re: REST Web Service Response JSON parsing

    ‏2013-04-04T16:00:44Z  
    Hi Neil,

    I am trying to use this from BPM implementation service. I have the response in string format. Need to parse that to IBM BPM Business Object ("Lombardi" variable to me :))

    Also I like to add that I always read your book before searching answer of the problem from any other source. And with the help two developer works article referred by you in the book I have successfully able to call the REST web service and set the response in a string. But now I hit a roadblock to parse that response back to Lombardi object IBM BPM Business Object.

    Bornik
    He he he ... like your use of strike-through.

    The technique I use to parse a JSON string into am object is:

    
    var jsObject = eval(
    "(" + jsonString + 
    ")"); var tw.local.myObject = jsObject; 
    // sometimes this is all we need to map otherwise field by field
    


    Neil
  • BornikChatterjee
    BornikChatterjee
    146 Posts

    Re: REST Web Service Response JSON parsing

    ‏2013-04-04T17:39:54Z  
    • kolban
    • ‏2013-04-04T16:00:44Z
    He he he ... like your use of strike-through.

    The technique I use to parse a JSON string into am object is:

    <pre class="jive-pre"> var jsObject = eval( "(" + jsonString + ")"); var tw.local.myObject = jsObject; // sometimes this is all we need to map otherwise field by field </pre>

    Neil
    Yes, it worked :). I was using a one step direct assignment earlier which is giving weird errors.

    Bornik
  • eplopes
    eplopes
    3 Posts

    Re: REST Web Service Response JSON parsing

    ‏2014-08-11T15:42:46Z  

    Hi guys,

    Do you know if its possible to pass the JSON string on the request body instead using the params in the URL when calling a service via REST?

    Instead of using /rest/bpm/wle/v1/service/.....&params={"a":"x", "b":"y"} that is really unpleasant to use for complex objects I just want to send my Inputs on the request body if possible.

     

    Thanks in advance

    Updated on 2014-08-11T15:43:24Z at 2014-08-11T15:43:24Z by eplopes
  • kolban
    kolban
    3322 Posts

    Re: REST Web Service Response JSON parsing

    ‏2014-08-11T17:37:11Z  
    • eplopes
    • ‏2014-08-11T15:42:46Z

    Hi guys,

    Do you know if its possible to pass the JSON string on the request body instead using the params in the URL when calling a service via REST?

    Instead of using /rest/bpm/wle/v1/service/.....&params={"a":"x", "b":"y"} that is really unpleasant to use for complex objects I just want to send my Inputs on the request body if possible.

     

    Thanks in advance

    Sure can.  See the following documentation page which I believes describes what you are looking for:

    http://www-01.ibm.com/support/knowledgecenter/SSFTN5_8.5.5/com.ibm.wbpm.bpc.doc/topics/rdev_restapis_httpmethods.html?lang=en