We recommend switching to the latest versions of Edge, Firefox, Chrome or Safari. Using Internet Explorer will result in a loss of website functionality.

Comments

3 comments

  • Avatar
    Adrian Williams

    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

     

    0
    Comment actions Permalink
  • Avatar
    Patrick Cassidy

    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

     

    0
    Comment actions Permalink
  • Avatar
    Adrian Williams

    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:

    0
    Comment actions Permalink

Please sign in to leave a comment.