Data360 Analyze

 View Only
  • 1.  Output to json

    Posted 10-07-2020 22:23

    Hi all,

    I'm needing to output my data into a JSON file.

    While I can read in the file with no issues I'm having trouble creating an output file into the format attached.

    Any help would be appreciated

     

    Attached files

    INC12341234_Sample_Test_1234.json

     



  • 2.  RE: Output to json

    Employee
    Posted 10-12-2020 05:14

    Attached is an example of using the json.dumps() method to create a serialized json string from field data. 

    The API and Script bindings section of the Help documentation describes the use of the fields.todict() method used in the example.

    You may also find this article useful https://stackabuse.com/reading-and-writing-json-to-a-file-in-python/ 

     

    The example only combines the data for a single transaction so in priactice you would need to combine the header data, refund data and salesforce case data for each transaction into a single record  and then acculate all of the transaction data in a list before serializing the overall json object.

     

     

    Attached files

    Output_JSON_Transactions--share - 12 Oct 2020.lna

     



  • 3.  RE: Output to json

    Posted 10-12-2020 18:15

    Awesome, Thanks heaps for the help.

    I've run your flow straight through and have tried outputting it using a CSV/Delimited output however the output looks to have a lot of extra quotes and \. I'm assuming I need to change some settings but couldn't find the right one

    Are you able to advise how I can generate a file for this?

     

    Attached files

    JSON_output_Test.json

     



  • 4.  RE: Output to json

    Employee
    Posted 10-13-2020 03:02

    It looks like the json.dumps() function includes the quotes and escaping backslashes when it serializes the python dictionary object containing the input field values to it's string representation - i.e. similar to using str(<dict_object>). I don't know of any optional settings that control this.

    You can write the json string to a file e.g. by modifying the code in the transform node similar to the following: