Skip to content

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

@noear

Description

@noear

目前只差 [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;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions