Issue swith jmespath and mongodb

Getting unworkable results from jmespath:

If I select the geometry.coordinates from the $json the closing bracket of the array’s ‘]’ are missing.

If I select the geometry element I get “[Object:” in front of the array, Mongo does not like that bit…

Please share the workflow

type or paste code here

Share the output returned by the last node

{
  "_id": "6410000cefa34562c3d8db32",
  "type": "Feature",
  "properties": {
    "fid": 248,
    "osm_id": null,
    "osm_way_id": "182839559",
    "landuse": "commercial",
    "name": null,
    "wikidata": null,
    "wikipedia": null,
    "path": ""
  },
  "geometry": {
    "type": "MultiPolygon",
    "coordinates": [
      [
        [
          [
            169.7759805,
            -20.248359
          ],
          [
            169.7762835,
            -20.2482332
          ],
          [
            169.7764524,
            -20.2484871
          ],
          [
            169.7754911,
            -20.2490026
          ],
          [
            169.7749499,
            -20.2489776
          ],
          [
            169.7745455,
            -20.2485565
          ],
          [
            169.7740493,
            -20.2484257
          ],
          [
            169.7740997,
            -20.2481915
          ],
          [
            169.7752108,
            -20.2483095
          ],
          [
            169.7757416,
            -20.2482276
          ],
          [
            169.7759805,
            -20.248359
          ]
        ]
      ]
    ]
  }
}

Information on your n8n setup

  • n8n version:0.219.1
  • Database you’re using (default: SQLite):
  • Running n8n with the execution process [own(default)]:
  • Running n8n via [Docker]:

Hey @Ido_Lelie,

That is an interesting one, I have had a quick play and it looks like something odd happens when you try to use text with the value almost like it is being converted to a string but not quite.

As a quick test can you try {{ JSON.stringify($json.geometry.coordinates) }} in my local test this seems to work ok to get the correct data and might work for you.

Yeah that works, thanks :+1:. Is this function in the documentation?

Hey @Ido_Lelie,

It is a javascript function so it won’t be in our documentation but you can find more about it here: JSON.stringify() - JavaScript | MDN

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.