christian Posted August 20, 2021 Posted August 20, 2021 Hi, I am new to ScriptMaster, so it could be, that I am doing something wrong. But let's start: I added a new script module with content as following: com.fasterxml.jackson.databind.ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper(); java.util.Map<String, String> map = mapper.readValue(json, Map.class); net.codecrete.qrbill.generator.Bill bill = new net.codecrete.qrbill.generator.Bill(); bill.setAccount(map.get("iban")); bill.setAmountFromDouble(Double.valueOf(map.get("amount").doubleValue()); bill.setCurrency(map.get("currency")); // Set creditor net.codecrete.qrbill.generator.Address creditor = new net.codecrete.qrbill.generator.Address(); creditor.setName(map.get("creditor.name")); creditor.setAddressLine1(map.get("creditor.address")); creditor.setAddressLine2(map.get("creditor.city")); creditor.setCountryCode(map.get("creditor.country")); bill.setCreditor(creditor); // more bill data bill.setReference(map.get("reference")); bill.setUnstructuredMessage(map.get("message")); // Set debtor net.codecrete.qrbill.generator.Address debtor = new net.codecrete.qrbill.generator.Address(); debtor.setName(map.get("debtor.name")); debtor.setAddressLine1(map.get("debtor.address")); debtor.setAddressLine2(map.get("debtor.city")); debtor.setCountryCode(map.get("debtor.country")); bill.setDebtor(debtor); // Generate QR bill return new net.codecrete.qrbill.generator.QRBill().generate(bill); I pass the following parameter: { "iban" : "CH4431999123000889012", "amount" : "199.95", "currency" : "CHF", "creditor.name" : "Robert Schneider AG", "creditor.address" : "Rue du Lac 1268/2/22", "creditor.city" : "2501 Biel", "creditor.country" : "CH", "reference" : "210000000003139471430009017", "message" : "Abonnement für 2020", "debtor.name" : "Pia-Maria Rutschmann-Schnyder", "debtor.address" : "Grosse Marktgasse 28", "debtor.city" : "9400 Rorschach", "debtor.country" : "CH", } I use these jars: Jackson-Databind-2.12.4.jar, Pdfbox-2.0.24.jar, Qrbill-Generator-2.5.3.jar and Qrcodegen-1.7.0.jar when I run the script I get the error Compilation failed: startup failed: Script1.groovy: 29: unexpected token: @ line 29, column 67. rator.QRBill().generate(bill); ^ 1 error Parameters: json={ "iban" : "CH4431999123000889012", "amount" : "199.95", "currency" : "CHF", "creditor.name" : "Robert Schneider AG", "creditor.address" : "Rue du Lac 1268/2/22", "creditor.city" : "2501 Biel", "creditor.country" : "CH", "reference" : "210000000003139471430009017", "message" : "Abonnement für 2020", "debtor.name" : "Pia-Maria Rutschmann-Schnyder", "debtor.address" : "Grosse Marktgasse 28", "debtor.city" : "9400 Rorschach", "debtor.country" : "CH", } ---Script--- Script: com.fasterxml.jackson.databind.ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper(); java.util.Map<String, String> map = mapper.readValue(json, Map.class); net.codecrete.qrbill.generator.Bill bill = new net.codecrete.qrbill.generator.Bill(); bill.setAccount(map.get("iban")); bill.setAmountFromDouble(Double.valueOf(map.get("amount").doubleValue()); bill.setCurrency(map.get("currency")); // Set creditor net.codecrete.qrbill.generator.Address creditor = new net.codecrete.qrbill.generator.Address(); creditor.setName(map.get("creditor.name")); creditor.setAddressLine1(map.get("creditor.address")); creditor.setAddressLine2(map.get("creditor.city")); creditor.setCountryCode(map.get("creditor.country")); bill.setCreditor(creditor); // more bill data bill.setReference(map.get("reference")); bill.setUnstructuredMessage(map.get("message")); // Set debtor net.codecrete.qrbill.generator.Address debtor = new net.codecrete.qrbill.generator.Address(); debtor.setName(map.get("debtor.name")); debtor.setA... But looking at the javacode everything should be ok! What could be the problem here? Thank you!
christian Posted August 20, 2021 Author Posted August 20, 2021 Solved (better: copied the content of the script and pasted it again, now it runs). 1
Recommended Posts
This topic is 1189 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now