JSON 框架 jfire-codejson

码农软件 · 软件分类 · JSON/BSON开发包 · 2019-03-30 23:41:44

软件介绍

jfire-codejson 是最快最自由的json框架,性能超越 fastjson 1 倍。支持策略能力。

已发布到maven中央仓库。link.jfire.codejson

性能强劲codejson是迄今为止最为强大的json框架,序列化速度超越fastjson 50%,超越Jackson2 40%。反序列化性能超越Fastjson几倍。自由定制输出codejson除了可以完成常规的对属性的忽略和改名以为。依靠强大的策略能力,可以对序列化的输出做出任意的修改。可以对同一个对象,使用不同的策略 进行不同的输出。充分满足不同场景的使用要求。策略能力可以进行属性改名,属性忽略,对输出内容格式化,对某一种格式进行各耍等等,只要能想得出来,策略 能力都可以做到。极致简单的API对于序列化来说,只需要使用类似JsonTool.write(entity)一行静态代码即可得到json字符串。 对于反序列化来说,只需要使用类似JsonTool.read(User.class,str)一行静态代码即可将json字符串反序列化为pojo对象

快速入门

假设存在以下几个类

public class Person{
    private String name;
    private int age;
    private boolean boy;}public class Home{
    privaet String name;
    private Person host;
    private float height;
    private float weidth;}public static void main(String args[]){
    Home home = new Home();
    home.setPerson(new Person());
    //这样就完成了将home转换为json字符串的动作
    String json = JsonTool.write(home);
    //这样就完成了将json字符串转换为json对象的动作
    JsonObject jsonObject =(JsonObject)jsonTool.fromString(json);
    //这样就完成了将json字符串转换为java对象的动作
    Home result = JsonTool.read(Home.class,json);

    WriteStrategy strategy = new WriteStrategy();
    //指定一个输出策略,将name这个属性名在输出的时候替换成hello
    strategy.addRenameField("Home.name", "hello");
    json = strategy.write(home);

    strategy = new WriteStrategy();
    //指定一个输出策略,将float输出的时候截止到小数点1位
    strategy.addWriter(float.class,new WriterAdapter(){
            public void write(float target,StringCache cache){
                  DecimalFormat format = new DecimalFormat("##.00");
                  cache.append(format.format(target));
           }
    });
    json = strategy.write(home);}

本文地址:https://codercto.com/soft/d/2522.html

Artificial Intelligence

Artificial Intelligence

Stuart Russell、Peter Norvig / Pearson / 2009-12-11 / USD 195.00

The long-anticipated revision of this #1 selling book offers the most comprehensive, state of the art introduction to the theory and practice of artificial intelligence for modern applications. Intell......一起来看看 《Artificial Intelligence》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试