Skip to content

Is it possible to represent a list consisting of multiple variables in the query converted into JSON? #380

@Montanaz0r

Description

@Montanaz0r

Hi @c-martinez @albertmeronyo! First of all, Thank you for your excellent work.

I do play with the tool you created for some time, and I was wondering if there is a way to represent a python-like list in the transformed JSON. The caveat is that the list should contain multiple variables that query extracts. Let me show you an example of what I am trying to achieve:

#+ "coordinates": [1.234, 3.555],

I can place a hardcoded list with two decimal values in the decorated transform clause. This will indeed allow me to represent a python-like list with multiple values separated by a comma, but I would like to replace those values with variables that are coming from the query. Just like this:

#+ "coordinates": [?a_variable, ?b_variable],

Unfortunately, this doesn't work and the JSON output doesn't produce what I was expecting. You can see the output below.

"coordinates": [ { "a_variable": null }, { "b_variable": null } ],

I have also tried capturing the whole list between "" and the same for variables inside the list, but it didn't help.

Is there any way I could achieve this? My specific goal is to capture latitude and longitude using the SPARQL query. Cast them both as decimals and represent the inside of a single list. For now, I ended up concatenating a string from both coordinates and closed brackets. However, this doesn't feel good.

Thank you in advance for your help!

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