Code Monkey home page Code Monkey logo

Comments (5)

zycgit avatar zycgit commented on May 19, 2024

升级到 4.1.6,然后在界面上自定义。
image

第二个方式就是,resultprocess 拦截器
https://www.hasor.net/web/dataway/spi.html#resultprocess

from hasor.

tzxylao avatar tzxylao commented on May 19, 2024

@zycgit 我想要实现的是返回结果忽略null字段,fastjson可以实现,就在我截图的图片位置,再给个配置参数就行,但在ResultProcessChainSpi这个调用链上没有response,返回值是对象,不能做这样的处理

from hasor.

tzxylao avatar tzxylao commented on May 19, 2024
   @Bean
    @Primary
    @ConditionalOnMissingBean(ObjectMapper.class)
    public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder) {
        ObjectMapper objectMapper = builder.createXmlMapper(false).build();
// 忽略null字段
        objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
        objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        objectMapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
        objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
        return objectMapper;
    }


    @JsonIgnore
    private Object source;

其实就是这样,本来我用jackson序列化,返回结果会自动去掉该字段,且null值字段也去掉,那么在此框架如何嵌入该功能

from hasor.

zycgit avatar zycgit commented on May 19, 2024

那还是 open 这个 issue 把,我以为你只是单纯的结果改写。

from hasor.

zycgit avatar zycgit commented on May 19, 2024

在 4.1.7 中会提供一个新的扩展接口 ResultSerializationChainSpi ,通过这个扩展接口可以实现自定义序列化。 可以提前 使用dev 分支来体验这一个功能。

same as #41

from hasor.

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.