Skip to content

Support multi-dimensional arrays when writing json (example geojson polygon) #237

@mlankamp

Description

@mlankamp

The current json-sink is not able to export Geojson correctly (probably because the cosmos source used Newtonsoft and writes using STJ).

Example json in cosmos

{
  "id": "1",
  "name": "Example",
  "point": {
    "type": "Point",
    "coordinates": [
      5.347494076316281,
      52.033503157065155
    ]
  },
  "polygon": {
    "type": "Polygon",
    "coordinates": [
      [
        [
          5.347432321215393,
          52.03355800306437
        ],
        [
          5.347432321215393,
          52.03343276598602
        ],
        [
          5.347605671445933,
          52.03343276598602
        ],
        [
          5.347605671445933,
          52.03355800306437
        ],
        [
          5.347432321215393,
          52.03355800306437
        ]
      ]
    ]
  },
  "line": {
    "type": "LineString",
    "coordinates": [
      [
        5.3474399338950604,
        52.03355740411766
      ],
      [
        5.347590198744001,
        52.033439655450024
      ]
    ]
  }
}

Export settings:

{
    "Source": "cosmos-nosql",
    "SourceSettings": {
        "ConnectionString": "--- replace ---",
        "Database": "--- replace ---",
        "Container": "--- replace ---"
    },
    "Sink": "JSON",
    "SinkSettings": {
        "FilePath": "D:\\export\\example.json",
        "IncludeNullFields": true,
        "Indented": true
    }
}

Result:

[
  {
    "id": "1",
    "name": "Example",
    "point": {
      "type": "Point",
      "coordinates": [
        5.347494076316281,
        52.033503157065155
      ]
    },
    "polygon": {
      "type": "Polygon",
      "coordinates": [
        "System.Collections.Generic.List`1[System.Object]"
      ]
    },
    "line": {
      "type": "LineString",
      "coordinates": [
        "System.Collections.Generic.List`1[System.Object]",
        "System.Collections.Generic.List`1[System.Object]"
      ]
    }
  }
]

The export of Geojson Point is possible because the coordinates is a simple number array, but for Polygon (and others) the coordinates is a multi-dimensional array.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions