msgspec-geojson
A collection of GeoJSON types for msgspec.
Inspired by the msgspec GeoJSON example code and geojson-pydantic.
This lets you parse GeoJSON into type-safe objects, including properties, and serialize those objects back to GeoJSON:
>>> import msgspec.json
>>> from msgspec import Struct
>>> from msgspec_geojson import Feature, Point
>>> class PoiProperties(Struct):
... name: str
... kind: str
>>> obj = msgspec.json.decode("""
... {"type": "Feature", "id": 1,
... "properties": {"name": "Zoo Zürich", "kind": "tourism/zoo"},
... "geometry": {"type": "Point", "coordinates": [8.574695, 47.384510]}}
... """, type=Feature[Point, PoiProperties])
>>> obj.id
1
>>> obj.geometry
Point(coordinates=(8.574695, 47.38451))
>>> obj.properties
PoiProperties(name='Zoo Zürich', kind='tourism/zoo')
>>> feature = Feature(
... Point(coordinates=(7.5823576, 47.5489249)),
... PoiProperties(name="Zoo Basel", kind="tourism/zoo"),
... )
>>> msgspec.json.encode(feature)
b'{"type":"Feature","geometry":{"type":"Point","coordinates":[7.5823576,47.5489249]},"properties":{"name":"Zoo Basel","kind":"tourism/zoo"}}'
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
msgspec_geojson-0.2.2.tar.gz
(2.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file msgspec_geojson-0.2.2.tar.gz.
File metadata
- Download URL: msgspec_geojson-0.2.2.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa8ab93b244ba1a5d935dcd24383d41dde0f87b83c74864d94eeeffb529d9ce9
|
|
| MD5 |
c6bcdde3aae3a1beedd319f992dc8edd
|
|
| BLAKE2b-256 |
16f92d24052e00e81bc21d4d40cf63830a3de538d79b49c5bdca8476f05c3b15
|
File details
Details for the file msgspec_geojson-0.2.2-py3-none-any.whl.
File metadata
- Download URL: msgspec_geojson-0.2.2-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05c25c2f707a3a0e10d6b3763efbcb65cdf851f76f538cc5ec429833883bed49
|
|
| MD5 |
1572f9eade5f539a4b744137f7846b8c
|
|
| BLAKE2b-256 |
a4d0ad68d9ddaa4c08a6ab7391a4ba526babde916fbbe2c931da438f2115b98a
|