#serialization #mapbox #maplibre #serde

tilejson

Library for serializing the TileJSON file format

15 releases

0.4.3 Jun 16, 2025
0.4.2 Mar 3, 2025
0.4.1 Dec 9, 2023
0.4.0 Nov 20, 2023
0.1.0 Nov 27, 2017

#105 in Geospatial

Download history 962/week @ 2025-08-02 893/week @ 2025-08-09 732/week @ 2025-08-16 1596/week @ 2025-08-23 829/week @ 2025-08-30 812/week @ 2025-09-06 2199/week @ 2025-09-13 1983/week @ 2025-09-20 2106/week @ 2025-09-27 1677/week @ 2025-10-04 1215/week @ 2025-10-11 958/week @ 2025-10-18 1305/week @ 2025-10-25 1775/week @ 2025-11-01 722/week @ 2025-11-08 567/week @ 2025-11-15

4,478 downloads per month
Used in 10 crates (8 directly)

MIT/Apache

53KB
699 lines

tilejson

GitHub repo crates.io version crate usage docs.rs status crates.io license CI build status Codecov

tilejson is a crate for serializing/deserializing the TileJSON format — an open standard for representing map metadata.

Examples

Reading

use tilejson::TileJSON;

fn main() {
    let tilejson_str = r#"{
        "tilejson": "3.0.0",
        "name": "compositing",
        "scheme": "tms",
        "tiles": [
            "http://localhost:8888/admin/1.0.0/world-light,broadband/{z}/{x}/{y}.png"
        ]
    }"#;

    // Parse JSON
    let mut tilejson: TileJSON = serde_json::from_str(&tilejson_str).unwrap();
    println!("{tilejson:?}");

    // Add missing default values per TileJSON specification
    tilejson.set_missing_defaults();
    println!("{tilejson:?}");
}

Writing

use tilejson::tilejson;

fn main() {
    let tilejson = tilejson! {
        "http://localhost:8888/admin/1.0.0/world-light,broadband/{z}/{x}/{y}.png".to_string(),
        name: "tileset name".to_string(),
        description: "some description".to_string(),
    };

    let serialized_tilejson = serde_json::to_string(&tilejson).unwrap();

    println!("{serialized_tilejson}");
}

Contributing

Contributions are welcome! Have a look at the issues, and open a pull request if you'd like to add an algorithm or some functionality.

Development

  • This project is easier to develop with just, a modern alternative to make. Install it with cargo install just.
  • To get a list of available commands, run just.
  • To run tests, use just test.

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual-licensed as above, without any additional terms or conditions.

Dependencies

~0.7–1.7MB
~36K SLoC