JSONPath.toPathArray returns different values for the same input · Issue #102 · JSONPath-Plus/JSONPath · GitHub
Skip to content

JSONPath.toPathArray returns different values for the same input #102

Description

@andalal

I am using the toPathArray method in the following way

const jsonpathTokens: string[] = JSONPath.toPathArray(propertyRef.propertyPath);

When I pass in the string "$.subsensor.temp" for the first time, it will return ["$", "subsensor", "temp"] as expected. However when the toPathArray is called again with the same input, it returns ["subsensor", "temp"]. This happens for other inputs of a similar type.

When I stepped through the debugger it seems like there is a JSONPath.cache object which is checked before the regex is run. I checked that the value saved to the cache exprList is correct. However on the immediate next call the cache object was already modified to exclude the "$".

I think this is a bug because the toPathArray method should return the same values for the same input.

I am using v1.0.0 and I'm using the library within typescript.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions