1 Reply Latest reply on Jul 12, 2019 6:41 PM by lakshmikanthareddy

    How to read json data in JBPM (Red Hat BPM)?

    karthik07m

      I am calling an API which gives back the data in the form JSON. I am storing it in a process variable. Whole JSON data is storing in the process variable. But I want to fetch particular fields only how can I achieve that. I am new to the JBPM

      I tried to use JSON dependices but no use

      This the json data. I'm geting [{"uid":"1","name":"marioseg","mail":"appianDrupal@test.com","created":"Thu, 06/06/2019 - 06:18","access":"Tue, 06/18/2019 - 06:01"},{"uid":"6","name":"ErwinIbarraV","mail":"weito@live.com","created":"Thu, 06/06/2019 - 09:27","access":"Mon, 06/10/2019 - 10:08"},{"uid":"11","name":"shubham","mail":"shubhams2@hexaware.com","created":"Mon, 06/10/2019 - 09:16","access":"Wed, 06/19/2019 - 07:43"},{"uid":"31","name":"mariom","mail":"molinarmario3@gmail.com","created":"Fri, 06/14/2019 - 06:36","access":"Wed, 06/19/2019 - 06:38"}]

      This  whole data is storing in the process variable. I want read individual data like only names etc

        • 1. Re: How to read json data in JBPM (Red Hat BPM)?
          lakshmikanthareddy

          You need to create the POJO class as per your API Response.

           

           

          For example

          String result ="jsobresponse";

          APIResponse resp =

                              (APIResponse ) Transformer.objectCreatorFromJSON(result, APIResponse .class);

           

           

          Create the Transformer util class and defined the method as below

           

              public static Object objectCreatorFromJSON(String jsonObj, Class<?> valueType)

                      throws IOException {

                  ObjectMapper mapper = new ObjectMapper();

                  return mapper.readValue(jsonObj, valueType);

              }