Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Unreleased
- feat: :doc:`/scripts/csvclean` adds a :code:`--remove-empty-columns` option to remove empty columns from standard output.
- feat: :doc:`/scripts/in2csv` guesses the ``ndjson`` format for files with :code:`.ndjson`, :code:`.jsonl` and :code:`.jl` extensions.
- fix: :code:`-C/--not-columns` now excludes the last column of an open-ended range (e.g. :code:`2-`).
- fix: :doc:`/scripts/in2csv` with :code:`--format geojson` serializes array-valued properties as JSON, like object-valued properties, instead of as a Python ``repr``.

2.2.0 - December 15, 2025
-------------------------
Expand Down
2 changes: 1 addition & 1 deletion csvkit/convert/geojs.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def geojson2csv(f, key=None, **kwargs):

for field in property_fields:
value = properties.get(field)
if isinstance(value, OrderedDict):
if isinstance(value, (OrderedDict, list)):
value = json.dumps(value)
row.append(value)

Expand Down
13 changes: 13 additions & 0 deletions tests/test_utilities/test_in2csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,19 @@ def test_geojson_no_inference(self):

input_file.close()

def test_geojson_array_property(self):
input_file = io.BytesIO(
b'{"type": "FeatureCollection", "features": [{"geometry": null, "properties": '
b'{"tags": ["a", "b"], "obj": {"k": "v"}}}]}')

with stdin_as_string(input_file):
self.assertLines(['-f', 'geojson'], [
'id,tags,obj,geojson,type,longitude,latitude',
',"[""a"", ""b""]","{""k"": ""v""}",null,,,',
])

input_file.close()

def test_json_no_inference(self):
input_file = io.BytesIO(b'[{"a": 1, "b": 2, "c": 3}]')

Expand Down