1 Reply Latest reply on Nov 3, 2016 5:02 AM by gopi.gorantala

    REST API Objects with Same Name

    wyatts1

      Hello,

       

      I have a question about refining the results from a search/people call. I want to extra data from the jive.profile.value objects. The problem I am having is when I export the results into a CSV, I am populating a single CSV cell with too much data. The data I am needing falls under the same object name, and will all go into a single cell. If I want the data from jive.profile.value, and want to split up the data from each object into a separate cell or have some way of appending a delimiter, how would I go about doing so? Please see example JSON below for visual representation of the issue.

       

                    EXAMPLE JSON DATA

      "jive" : {

      "profile" : [ {

        "jive_label" : "Title",

        "value" : "TITLE DATA",

        "jive_displayOrder" : 0,

        "jive_summaryDisplayOrder" : 0,

        "jive_showSummaryLabel" : true

        }, {

        "jive_label" : "Employee Type",

        "value" : "EMPLOYEE TYPE DATA",

        "jive_displayOrder" : 4,

        "jive_summaryDisplayOrder" : 4,

        "jive_showSummaryLabel" : true

        }, {

        "jive_label" : "Legal Name",

        "value" : "LEGAL NAME DATA",

        "jive_displayOrder" : 5,

        "jive_showSummaryLabel" : false

        }, {

        "jive_label" : "Employee ID",

        "value" : "EMPLOYEE ID DATA",

        "jive_displayOrder" : 6,

        "jive_showSummaryLabel" : false

        }, {

        "jive_label" : "User Name",

        "value" : "EMPLOYEE ID DATA",

        "jive_displayOrder" : 7,

        "jive_showSummaryLabel" : false

        }, {... and so on...

       

      RESULT CSV (What my data output looks like in the CSV)

       

      |                                                         jive.profile.value OUTPUT                                                                   |

       

      +-------------------------------------------------------------------------------------------------------------------------------------------+

      | TITLE DATA EMPLOYEE TYPE DATA LEGAL NAME DATA EMPLOYEE ID DATA EMPLOYEE ID DATA |

      +-------------------------------------------------------------------------------------------------------------------------------------------+

       

      I cannot split up the data in excel because there is not clear delimiter since some of the data includes spaces. Any suggestions are appreciated! Thanks again!

        • Re: REST API Objects with Same Name
          gopi.gorantala

          Check for each condition like below and form a valid response and send it to csv file.

           

          for (var jsonObj in response.jive.profile) {

          if ((response.jive.profile[jsonObj].jive_label === 'Employee Type')) {

                    response.jive.profile[jsonObj].value  // you get the value here, repeat for all others and get all values

             }

          }

           

          for each above condition you get the type and its value,  add a delimeter and then proceed for other if loops.

          1 person found this helpful