• Gson的两种实例化方式:


    2018-11-13   09:21:44

    Gson的两种实例化方式:

    1: 使用new Gson(); 普通实例化方式,不能配置定制化选项

    Gson gson = new Gson(); 

    2: 通过GsonBuilder 可以配置多种选项

    Gson gson = new GsonBuilder().setLenient()// json宽松  
            .enableComplexMapKeySerialization()//支持Map的key为复杂对象的形式  
            .serializeNulls() //智能null,支持输出值为null的属性
            .setPrettyPrinting()//格式化输出(序列化)
            .setDateFormat("yyyy-MM-dd HH:mm:ss") //序列化日期格式化输出 
            .excludeFieldsWithoutExposeAnnotation() //不序列化与反序列化没有@Expose标注的字段
    
            .disableHtmlEscaping() //默认是Gson把HTML转义的  
            .create();
  • 相关阅读:
    shell:bash基本特性
    python_day02
    python_day01
    centos环境下安装python3以及pip3
    http1到http3的巨大变化
    HTTP协议
    bootstrap
    JQuery
    BOM与DOM
    23种设计模式的几种常见的设计模式
  • 原文地址:https://www.cnblogs.com/yanchaohui/p/9950480.html
Copyright © 2020-2023  润新知