psbds / vscode-jsonmap

The JsonMap extension provides the capabilities of running javascript commands like: map, filter, find, reduce and more in your open Json files.
Apache License 2.0
0 stars 0 forks source link

data.find is not a function; data.filter is not a function; data.map is not a function #10

Open csaper opened 2 years ago

csaper commented 2 years ago

Hi there @psbds --

I'm testing out the VSCode JsonMap extension. After opening a JSON file, running the JsonMap: Open Command Parser command and entering a parse command like data.filter(x => x.id > 12), data.find(x => x.name == "Foo"), or data.map(x => x.title) the extension host displays the errors data.filter is not a function, data.find is not a function and data.map is not a function, respectively.

data filter, data find, data map is not a function

JsonMap v0.1.1 Visual Studio Code v1.68.0 macOS v12.4

Let me know if I can provide any more information to aid in debugging.

psbds commented 2 years ago

Hello @csaper, sorry for the late response.

Could try to execute the following test:

  1. Create a json file with the following content
    [
    {
        "id": 1,
        "title": "Lorem ipsum 1"
    },
    {
        "id": 2,
        "title": "Lorem ipsum 2"
    }
    ]
  2. Execute the parser with the command: data.map(x => x.title)

As I'm unable to test this on macOS, so I'm trying to pinpoint if the issue is related to the Json not being able to be parsed or if it's related to the environment.

The part where the extension execute the eval if very simple so is highly possible that a unscaped character could led to this error https://github.com/psbds/vscode-jsonmap/blob/adf13bf4660b7684ba351059fc12b36c6915226f/src/ParserExtension.ts#L79-L84