June 03, 2016

[Download] EAI JSON Converter v2

Pleased to bring you the complete EAI JSON Converter v2. It happened a lot sooner than I expected.
Siebel EAI JSON Converter

Below is the code which converts JSON string to property set. The heart of the code is eval statement, which converts the JSON string into eScript Object. 
Siebel eval statement

Remaining code is just the recursive traversing to convert object into property set. I have tested the code for couple JSON strings, it passed everytime with flying colours every time. Feel free to change the code as required. 

You can download the complete sif from git hub. https://github.com/Jimjson/eScript-based-EAI-JSON-Converter-


EAI JSON Converter Demo: 

24 comments :

  1. Post in on OracleSiebel Git!

    Jeroen

    ReplyDelete
  2. Just created a pull request. Over to oracle now.

    ReplyDelete
  3. Hello!

    I use this service in the Workflow Process


    My steps:
    1) Start

    2) EAI HTTP Transport (SendReceive)
    input
    = "{name: '" + [& Login] + "', password: '" + [& Pass] + "', IDTask: '" + [& Task] + "'', cardnumber: ['" + [ & CardNum] + " ']}"
    HTTPRequestMethod = POST
    HTTPContentType = pplication / x-www-form-urlencoded; charset = UTF-8 \ r \ n
    HTTPUserAgent = Siebel \ r \ n
    HTTPRequestURLTemplate = Https: // Url
    Output
    RespBinary =
    EndOfData = EndOfData
    TimedOut = TimedOut

    3) Transcode the Service (Convert)
    input
    TargetEncoding = UTF-16
    SourceEncoding = UTF-8
    ConversionMode = EncodingToString
    = RespBinary
    output
    RespBinary =

    4) EAI JSON Converter (JSONToPropset)
    input
    ConvertJSONtoPS = RespBinary

    In Step 4, I get the following error:
    Error invoking service 'EAI JSON Converter', method 'JSONToPropset' at step 'Business Service 0'. (SBL-BPR-00162)
    -
    Unhandled Exception: Syntax error at Line 2 position 1: Unknown syntax error.


    Service.ConvertJSONtoPS line: 7
    Service.Service_PreInvokeMethod line: 100




    Large please tell how to avoid this error.

    Thank you

    ReplyDelete
    Replies
    1. Hi Sergey, Thanks for trying this out. I get the same error if I am transcoding it from UTF-16 to String, however it doesn't come when I do conversion from UTF-8. Try UTF-8 once and let me know, if you still get this error. I will soon create demo workflow to show how this service can be used directly. -Jim

      Delete
    2. Yes, the problem persists.

      Thank you for the quick response. I expect from you a demonstration of the WF with the use of this service.

      Delete
    3. Hi Sergey, I have created screencast demo and uploaded on to youtube. https://www.youtube.com/watch?v=B2a6mGxQwzU

      hope it helps.

      Delete
  4. Hello Sergey,
    This is Gold. If possible can you post example of REST API call which takes input as JSON and returns response. t will be great help. Many thanks again.

    Regards,
    -Rahul

    ReplyDelete
  5. Hello ,

    When I use eval() function its taking more than 10 min siebel. Please let me know do you have any other solution.


    ReplyDelete
  6. And if we have more than one child its not showing like [] object list in json fomrat

    ReplyDelete
  7. Hi vijay,i noticed that it takes more time when JSON is not properly formatted .

    I faced same issue with duplicate child elements, that is why i added index for every child. Download the sif file from github and try. In example video you can see the prefix.

    ReplyDelete
  8. You can use original EAI JSON Converter if escript version doesn't work for you.

    http://howtosiebel.blogspot.com/2013/12/eai-json-converter.html

    ReplyDelete
  9. Even that one also having same issues for child's . Its not having Proper [] Object list .And I am getting only one child at the end even if I have more than 10 child's.

    ReplyDelete
  10. Hi vijays, could you please share JSON structure, would like to see what's going on.

    ReplyDelete
  11. Hi,

    I faced same issue "Error invoking service 'PF EAI JSON Converter', method 'JSONToPropset' at step 'JSON to PropSet'.(SBL-BPR-00162)"

    I found this SR in Oracle Siebel Support <<>> and made the proposed changes. I deleted the step "Transcode UTF-8..." and add the Input Parameter "CharSetConversion"=UTF-8 to step "GetJSON". I also modified the step "JSON to PropSet" and change the property Name JSON String to JSON.

    Regards,
    Jose Luis

    ReplyDelete
  12. Jim Morse -Can you only show how to use the EAI HTTP Transport menhod SendResive the POST method to pass a JSON string?

    ReplyDelete
  13. http://howtosiebel.blogspot.com/2014/02/siebel-twitter-integration-part-1.html have a look at the example shown in this link. It works quite well.

    ReplyDelete
  14. Sergey , it looks like it is an issue specific to your server, can you try sending JSON to
    http://jsontest.com/
    And compare the difference.

    ReplyDelete
  15. Hi Jim,

    I am also getting similar error while simulating the workflow which you have uploaded in Youtube.Please find below error:
    Error invoking service 'EAI JSON Converter', method 'JSONToPropset' at step 'JSON To PropertySet'.(SBL-BPR-00162)
    --
    Siebel eScript runtime error occurred in procedure 'ObjectToPS' of Service [EAI JSON Converter]:

    (SBL-SCR-00141)
    --
    Stack trace:
    Service [EAI JSON Converter].ObjectToPS(), Line: 75
    Service [EAI JSON Converter].ConvertJSONtoPS(), Line: 14
    Service [EAI JSON Converter].Service_PreInvokeMethod(), Line: 101

    ReplyDelete
  16. when I convert JSON to property set, values is having with "" for example - "Account"

    ReplyDelete
  17. Even that one also having same issues for child's . Its not having Proper [] Object list .And I am getting only one child at the end even if I have more than 10 child's. Solution- I have fixed in the e script if you have more than one child ..

    ReplyDelete
  18. Hi vijays could you please share your code?

    ReplyDelete
  19. when I convert JSON to property set, values is having with "" for example - "Account". that is wrong it should be Just value with out "".

    public static SiebelPropertySet JsonObjectToPropertySet(JsonObject obj, SiebelPropertySet ps)

    {
    Iterator> iterator = obj.entrySet().iterator();
    SiebelPropertySet child;
    while (iterator.hasNext())
    {
    JsonArray jsonArray = new JsonArray();
    JsonObject jsonObject = new JsonObject();
    Map.Entry mapEntry = (Map.Entry) iterator.next();
    if(mapEntry!=null)
    {
    JsonElement jsonelement = (JsonElement) mapEntry.getValue();
    if(jsonelement.isJsonArray())
    {
    jsonArray = jsonelement.getAsJsonArray();
    child = new SiebelPropertySet();
    child.setType(mapEntry.getKey().toString());
    for(int i=0; i<jsonArray.size();i++){
    if(jsonArray.get(i).isJsonObject() || jsonArray.get(i).isJsonArray())
    {
    SiebelPropertySet temp = new SiebelPropertySet();
    temp.setType(mapEntry.getKey().toString());
    child.addChild(JsonObjectToPropertySet(jsonArray.get(i).getAsJsonObject(),temp));
    }
    else
    child.setProperty("" + i, jsonArray.get(i).getAsString());
    }
    ps.addChild(child);
    }
    else if(jsonelement.isJsonObject())
    {
    jsonObject = jsonelement.getAsJsonObject();
    child = new SiebelPropertySet();
    child.setType(mapEntry.getKey().toString());
    ps.addChild(JsonObjectToPropertySet(jsonObject, child));
    } else
    {
    ps.setProperty(mapEntry.getKey().toString(),mapEntry.getValue().toString());
    }
    }
    }

    return ps;
    }

    ReplyDelete
  20. Hi

    When using the method (JSONToPropset) at the output I get this kind of response (RESPONSE: object Object Error: Code 0 Message)

    I need to convert this method is performed in PropSet

    just such a JSON string
    { "Error": { "Code": 0,"Message":""},"Response":[{"cardnumber":"1234567891234568","Error":{"Code":0,"Message":""},"Response":[{"state":"Y","soft":{"Code":0},"hot":{"StopDT":"20160719", "PurgeDT": "20200719", "Code": 827, "Message": "NON -ACTIVATED CARD"}}]}]}

    Please tell me how to convert a JSON string in PropSet?

    ReplyDelete
    Replies
    1. Hi sergey, sorry i am too busy with my current assignment, would have tried it out otherwise. Jim

      Delete