snack3 icon indicating copy to clipboard operation
snack3 copied to clipboard

【任务发放】v4 增加 SQL/JSON Path Language(ISO/IEC 9075)支持

Open noear opened this issue 2 months ago • 0 comments

目前只差 [start to end] 语法支持。。。其它都可以扩展支持。比如:@.a starts with 'a' (支持操作符有空隔)

public class OperatorDemo {
    public static void main(String[] args) {
        //::定制操作符(已预置)
        OperatorLib.register("starts with", (ctx, node, term) -> {
            ONode leftNode = term.getLeftNode(ctx, node);

            if (leftNode.isString()) {
                ONode rightNode = term.getRightNode(ctx, node);
                if (rightNode.isNull()) {
                    return false;
                }

                return leftNode.getString().startsWith(rightNode.getString());
            }
            return false;
        });

        //::检验效果
        assert ONode.ofJson("{'list':['a','b','c']}")
                .select("$.list[?@ startsWith 'a']")
                .size() == 1;
    }
}

noear avatar Oct 16 '25 04:10 noear