ozimov / spring-boot-email-tools

A set of services and tools for sending emails in a Spring Boot 1.5.x application using a Template Engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support JSON for using spring-boot-email-tools as services/microservices over REST

edwardchanjw opened this issue · comments

Is that able to support json like following:
Any guidelines for how to extend thymeleaf for the purpose? or it is already supported?
or just which library convert them back to java POJO assumed the type retaining well.

For example Template with json

Tu quoque, <em>${item.stock.stockLocation}</em>!

        String json = "{\"price\": 22, \"name\":  \"product name\",  \"stock\":  { \"stockLocation\":  \"location\"  }}";
        map = mapper.readValue(json, new TypeReference<Map<String, String>>(){});
        final Map<String, Object> modelObject = new HashMap<>();
        modelObject.put("item", map);

emailService.send(email, "idus_martii.ftl", modelObject);

commented

If you are using sping-boot, just import 'com.google.code.gson:gson' as dependency and see this link JSON to Map at stackoverflow

Thanks for pointing me! I seldom work in Java land. Do using gson having some edge case on conversion, if work with other polyglot clients? Can't afford to go to using json schema. I only know about this two approach, I guess that the different approach for type safe and non-type safe language. But all thing can be manually verify right? just the decimal, double, long might be critical for certain applications.

Feel like I with this notable guy. Link