其他分享
首页 > 其他分享> > Snack3 3.2 发布,轻量的Json+Jsonpath框架

Snack3 3.2 发布,轻量的Json+Jsonpath框架

作者:互联网

Snack3 是一个轻量的 JSON + Jsonpath 框架。

借鉴了 Javascript 所有变量由 var 申明,及 Xml dom 一切都是 Node 的设计。其下一切数据都以ONode表示,ONode也即 One node 之意,代表任何类型,也可以转换为任何类型。

<dependency>
  <groupId>org.noear</groupId>
  <artifactId>snack3</artifactId>
  <version>3.2.7</version>
</dependency>

本次累计更新:

public class DemoTest {
    public void test(UserDto user) {
        Options options = Options.def();
        options.addEncoder(Date.class, (data, node)->{
            node.val().setNumber(data.getTimes());
        });
        
        ONode oNode = ONode.loadObj(user, options);
    }
}
public class UserModel {
    public int id;
    @ONodeAttr(serialize = false)
    public String name;
    @ONodeAttr(deserialize = false)
    public String note;
    @ONodeAttr(format = "yyyyMMdd")
    public Date date;
}
@lombok.Data
public class Data<X> {
    private List<X> content;
    private X obj;
    private int pageNum;
    private int pageSize;
    private int totalElements;
    private int pages;
}

@lombok.Data
public class House {
    private String sn;
    private String dver_type;
    private String data_status;
    private String created_by;
    private String updated_by;
    private String updated_date;
}

@lombok.Data
public class Result<T> {
    private int code;
    private Data<T> data;
}


Result<House> result = ONode.deserialize(json, new Result<House>() {}.getClass());
public class Server {
    public static class One{
        public int id;
        public String name;
    }
}

Server.One one = ONode.deserialize(json, Server.One.class);

项目地址:

标签:ONode,String,Snack3,int,private,class,Json,轻量,public
来源: https://www.cnblogs.com/noear/p/15777889.html