Skip to content

JSONPath supports function evaluation from global scope #53

Closed
@quantumlicht

Description

@quantumlicht

For me this is actually not a bug, but a useful feature that could be more user friendly or implemented in a better way.

By reading the source code it seems that the eval function has access to the global scope when evaluating expressions in parenthesis.

For instance, if I first define a parsing function, say:

parser = function(param){console.log(param);return '1,2,3,4,5'};

I can do something like that

JSONPath({},data, '$..book[0].category[(parser\(@\))]')

Where data is the same json as defined in the doc. Would it be possible to implement a regexp parser using this method?

I feel like regular expression is a missing feature in general and I would prefer not to use this hack.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions