cancel
Showing results for 
Search instead for 
Did you mean: 

Setting a list of maps through query parameters inside Neo4j browser

jpbarbosa
Node Link

Hello,

While playing with queries using Neo4j Browser, sometimes is helpful to set query parameters in advance so those variables can be easily changed without modifying the query itself. I could do that with simple parameters or even maps:

:param {
    personName: "Val Kilmer",
    movieTitle: "Top Gun"
}

But, when I try to nest maps inside a list like the below I get a syntax error:

:param items => [
    {
        personName: "Val Kilmer",
        movieTitle: "Top Gun"
    },
    {
        personName: "Tom Cruise",
        movieTitle: "Top Gun"
    }
]
// Returns

Syntax error at line 2 col 0:

      {
  ^
Unexpected "\n". 

Funny enough, it works while running the command in a single-line way:

:param items => [{personName: "Val Kilmer", movieTitle: "Top Gun"}, {personName: "Tom Cruise", movieTitle: "Top Gun"}]

Although, whenever I need to set many query parameters, the single-line approach above lacks readability.

Does anyone how to set a list of maps using that ":param" command in a multiline way?  

Thank you.

2 REPLIES 2

glilienfield
Ninja
Ninja

I don't know, but you could author the json in a json formatter (online or locally) and format to 'minify' or 'compact' format and paste the single line in the browser. It renders nice if you return the parameters with ':params'

https://jsonformatter.org

jpbarbosa
Node Link

I've just find a way:

:param {
    items: [
        {
            personName: "Val Kilmer",
            movieTitle: "Top Gun"
        },
        {
            personName: "Tom Cruise",
            movieTitle: "Top Gun"
        }
    ]
}

@glilienfield thank you for your tip, but I was trying to avoid additional steps for this specific workflow I am working on.

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.