cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Setting a list of maps through query parameters inside Neo4j browser

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

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

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.