Giter Site home page Giter Site logo

Comments (8)

noear avatar noear commented on July 2, 2024 1

现在是 protect 保护的,下版改成:public 了:)

from solon.

noear avatar noear commented on July 2, 2024

目前提供了一定的定制能力。你看是不是够用?

public class App {
    public static void main(String[] args) {
        Solon.start(App.class, args, app -> {
            //通过事件,订阅 JacksonRenderFactory 。进而定制转码和编码器
            app.onEvent(JacksonRenderFactory.class, factory -> initMvcJsonCustom(factory));
        });
    }

    /**
     * 初始化json定制(需要在插件运行前定制)
     */
    private static void initMvcJsonCustom(JacksonRenderFactory factory) {
        //通过转换器,做简单类型的定制
        factory.addConvertor(Date.class, s -> s.getTime());

        factory.addConvertor(LocalDate.class, s -> s.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));

        factory.addConvertor(LocalDateTime.class, s -> s.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")));

        //使用原生接口添加编码器
        factory.addEncoder(Date.class, new JsonSerializer<Date>() {
                    @Override
                    public void serialize(Date date, JsonGenerator out, SerializerProvider sp) throws IOException {
                        out.writeNumber(date.getTime());
                    }
                });
    }
}

from solon.

lost22git avatar lost22git commented on July 2, 2024

需要能够 installModules 和 enable/disable 一些 features 🤔

from solon.

noear avatar noear commented on July 2, 2024

那,我下一版把它放出来:)

from solon.

noear avatar noear commented on July 2, 2024
public class App {
    public static void main(String[] args) {
        Solon.start(App.class, args, app -> {
            //通过事件,订阅 JacksonRenderFactory 。进而定制转码和编码器
            app.onEvent(JacksonRenderFactory.class, factory -> initMvcJsonCustom(factory));
        });
    }

    private static void initMvcJsonCustom(JacksonRenderFactory factory) {
          factory.config() //下一版,它就是 ObjectMapper 对象了
    }
}

from solon.

noear avatar noear commented on July 2, 2024

1.10.1 发布了试试看

from solon.

lost22git avatar lost22git commented on July 2, 2024

建议在文档上提示:

需要在 web 模块中排除 snack3 模块

  implementation("org.noear:solon-web") {
    exclude(group : "org.noear", module : "solon.serialization.snack3")
  }
  implementation("org.noear:solon.serialization.jackson")

from solon.

noear avatar noear commented on July 2, 2024

是的要移除一下:)

from solon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.