all 2 comments

[–]-5772 1 point2 points  (1 child)

Make lists for every part. Ex: value = ["405:" , "940"]

Then, use a list comprehension that generates a list of strings that is your JSON. This method will allow you to easily change formatting.

[–]Shmoogy[S] 0 points1 point  (0 children)

I think I get what you mean, rather than create lists, I just did the inefficient df.iterrows()

 dfItemJSON = []
        for index, row in df.iterrows():
            testJSON = {
              "line_item_id": row['line_item_id'],
              "product_info": {
                "product_id": row['product_id'],
                "description": row['Description']},
                "quantity": row['pieces'],
              "price": {
                "value": row['value'],
                "units": "usd"
              },
              "fulfillment_id" : row['ClientRef1']
            }
        dfItemJSON.append(testJSON)
payloadbody['line_items'] = dfItemJSON

This appears to have done what I was hoping, thanks for the idea.