Hallo Zusammen,
ich versuche mit Hilfe des TextHTMLWriter aus einer Master-Child Database Kopfdaten und Auftragspositonen in ein JSON String einzubauen.
Als Vorlage habe ich folgendes erhalten.
{ "version": 0, "broker": "string", "fromMobile": true, "clientIp": "string", "id": "string", "oldid": "string", "ordertime": "2021-02-21T15:46:15.253Z", "deliverytime": "2021-02-21T15:46:15.253Z", "customerinfo": "string", "orderprice": 0, "orderdiscount": 0, "bonuscard": "string", "notification": true, "deliverycost": 0, "tip": 0, "customer": { "phone": "string", "email": "user@example.com", "companyname": "string", "departmentname": "string", "name": "string", "street": "string", "zip": "string", "location": "string", "addressinfo": "string" }, "payment": { "type": 0, "provider": "string", "transactionid": "string", "prepaid": 0 }, "items": [ { "uid": "string", "count": 0, "name": "string", "info": "string", "price": 0, "items": [ null ] } ] }
Mein Freemarker Script sieht auch ziemlich gut aus. Lediglich das "items" Objekt, in diesem die einzelnen Positionen aus der Child Database reinkommen müssten, bereitet mir ziemlich Kopfzerbrechen. Ich komme einfach nicht dahinter, wie ich das list row.children einbauen muss, damit ich die items im oben gewünschten Format reinbekomme
{ <#list spreadsheet@SearchMasterDatastore_10.getRows() as row> "version": 0, "broker": "Shop", "id": "${row.get("order_number")!}", "ordertime": "${row.get("created_at")!}", "deliverytime": "${row.get("created_at")!}", "customerinfo": "${row.get("customer_note")!}", "orderprice": ${row.get("total_price")!}, "orderdiscount": ${row.get("total_discounts")!}, "notification": ${row.get("shipping_lines_title")!}, "tip": ${row.get("total_tip_received")!}, "customer": { "phone": "${row.get("customer_default_address_phone")!}", "email": "${row.get("customer_email")!}", "companyname": "", "departmentname": "", "name": "${row.get("shipping_address_first_name")!} ${row.get("shipping_address_last_name")!}", "street": "${row.get("shipping_address_address1")!}", "zip": "${row.get("shipping_address_zip")!}", "location": "${row.get("shipping_address_city")!}", "addressinfo": "${row.get("shipping_address_address2")!}" }, "payment": { "type": ${row.get("gateway_type")!}, "provider": "${row.get("gateway_provider")!}", "transactionid": "${row.get("token")!}", "prepaid": ${row.get("total_price")!} }, "items": [ <#list row.children() as ch> { "count": ${ch['line_items_quantity']!}, "name": "${ch['line_items_name']!}", "price": ${ch['line_items_price']!}, "items": [ null ] } </#list> ] </#list> }
Viele Grüße
Ramin